home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / utility / sfs100.zip / SFS2.DOC < prev    next >
Text File  |  1994-02-20  |  117KB  |  2,046 lines

  1. The Care and Feeding of Passwords
  2. ---------------------------------
  3.  
  4. With the inherent strength of an encryption system like the one used by SFS,
  5. the password used for encryption is becoming more the focus of attack than the
  6. encryption system itself.  The reason for this is that trying to guess an
  7. encryption password is far simpler than trying to break the encryption system.
  8.  
  9. SFS allows keys of up to 100 characters in length.  These keys can contain
  10. letters, numbers, spaces, punctuation, and most control and extended characters
  11. except backspace (which is used for editing), escape (which is used to abort
  12. the password entry), and carriage return or newline, which are used to signify
  13. the end of the password.  This fact should be made use of to the fullest, with
  14. preferred passwords being entire phrases rather than individual words (in fact
  15. since very few words are longer than the SFS absolute minimum password length
  16. of 10 characters, the complete set of these words can be checked in moments).
  17. There exist programs designed to allow high-speed password cracking of standard
  18. encryption algorithms which can, in a matter of hours (sometimes minutes, even
  19. seconds in the case of very weak algorithms), attempt to use the contents of a
  20. number of very large and complete dictionaries as sample passwords[1].
  21.  
  22. Virtually all passwords composed of single words can be broken with ease in
  23. this manner, even in the case of encryption methods like the one which is used
  24. by SFS, which has been specially designed to be resistant to this form of
  25. attack (doing a test of all possible 10-letter passwords assuming a worst-case
  26. situation in which the password contains lowercase letters only, can be
  27. accomplished in 450,000 years on a fast workstation (DEC Alpha) if the attacker
  28. knows the contents of the encrypted volume in advance - or about 4 1/2 years on
  29. a network of 100,000 of these machines).  Of course no attacker would use this
  30. approach, as few people will use every possible combination of 10 letter
  31. passwords.  By using an intelligent dictionary-based cracking program, this
  32. time can be reduced to only a few months.  Complete programs which perform this
  33. task and libraries for incorporation into other software are already widely
  34. available. This problem is especially apparent if the encryption algorithm used
  35. is very weak - the encryption used by the popular Pkzip archiver, for example,
  36. can usually be broken in this manner in a few seconds on a cheap personal
  37. computer using the standard wordlist supplied with all Unix systems.
  38.  
  39. Simple modifications to passwords should not be trusted.  Capitalizing some
  40. letters, spelling the words backwards, adding one or two digits to the end, and
  41. so on, only present a slightly more difficult challenge to the average
  42. password-cracker than plain unadorned passwords.  Any phrase which could be
  43. present in any kind of list (song lyrics, movie scripts, books, plays, poetry,
  44. famous sayings, and so on) should not be used - again, these can be easily and
  45. automatically checked by computers.  Using foreign languages offers no extra
  46. security, since it means an attacker merely has to switch to using
  47. foreign-language dictionaries (or phrase lists, song lyrics, and so on).
  48. Relying on an attacker not knowing that a foreign language is being used ("If I
  49. use Swahili they'll never think of checking for it" - the so-called "Security
  50. through obscurity" technique) offers no extra security, since the few extra
  51. days or months it will take them to check every known language are only a minor
  52. inconvenience.
  53.  
  54. Probably the most difficult passwords to crack are ones comprising unusual
  55. phrases or sentences, since instead of searching a small body of text like the
  56. contents of a dictionary, book, or phrase list, the cracker must search a much
  57. larger corpus of data, namely all possible phrases in the language being used.
  58. Needless to say, the use of common phrases should be avoided, since these will
  59. be an obvious target for crackers.
  60.  
  61. Some sample bad passwords might be:
  62.  
  63.     misconception               Found in a standard dictionary
  64.     noitpecnocsim               Reversed standard dictionary word
  65.     miskonseption               Simple misspelling of a standard word
  66.     m1skon53pshun               Not-so-simple misspelling of a standard word
  67.     MiScONcepTiON               Standard word with strange capitalization
  68.     misconception1234           Standard word with simple numeric code appended
  69.     3012261726                  Simple numeric code, probably a US phone number
  70.     YKYBHTLWYS                  Simple mnemonic
  71.  
  72. In general coming up with a secure single-word password is virtually impossible
  73. unless you have a very good memory for things like unique 20-digit numbers.
  74.  
  75. Some sample bad passphrases might be:
  76.  
  77.     What has it got in its
  78.      pocketses?                 Found in a common book
  79.     Ph'n-glui mgl'w naf'h
  80.       Cthulhu R'yleh w'gah      Found in a somewhat less common book
  81.     For yesterday the word of
  82.       Caesar might have stood   Found in a theatrical work
  83.     modify the characteristics
  84.       of a directory            Found in a technical manual
  85.     T'was brillig, and the
  86.       slithy toves              Found in a book of poetry
  87.     I've travelled roads that
  88.       lead to wonder            Found in a list of music lyrics
  89.     azetylenoszilliert in
  90.       phaenomenaler kugelform   Found in an obscure foreign journal
  91.     Arl be back                 Found in several films
  92.     I don't recall              Associated with a famous person (although
  93.                                 it does make a good answer to the question
  94.                                 "What's the password?" during an
  95.                                 interrogation)
  96.  
  97. Footnote [1]: A large collection of dictionaries suitable for this kind of
  98.               attack can be found on black.ox.ac.uk in the `wordlists'
  99.               directory.  These dictionaries contain, among other things, 2MB
  100.               of Dutch words, 2MB of German words, 600KB of Italian words,
  101.               600KB of Norwegian words, 200KB of Swedish words, 3.3MB of
  102.               Finnish words, 1MB of Japanese words, 1.1MB of Polish words,
  103.               700KB of assorted names, and a very large collection of assorted
  104.               wordlists covering technical terms, jargon, the Koran, the works
  105.               of Lewis Carrol, characters, actors, and titles from movies and
  106.               plays, Monty Python, Star Trek, US politics, US postal areas, the
  107.               CIA world fact book, the contents of several large standard
  108.               dictionaries and thesaurii, and common terms from Australian,
  109.               Chinese, Danish, Dutch, French, German, Italian, Japanese,
  110.               Norwegian, Polish, Spanish, Swedish, Yiddish, computers,
  111.               literature, places, religion, and scientific terms.
  112.  
  113.               The black.ox.ac.uk site also contains, in the directory
  114.               /src/security/cracklib25.tar.Z, a word dictionary of around 10MB,
  115.               stored as a 6MB compressed tar file.
  116.  
  117.               A large dictionary of English words which also contains
  118.               abbreviations, hyphenations, and misspelled words, is available
  119.               from wocket.vantage.gte.com in the pub/standard_dictionary as
  120.               dic-0294.tar, an uncompressed 8.9MB file, or dic-0294.tar.Z, a
  121.               compressed 4.1MB file, and contains around 880,000 entries.  In
  122.               combination with a Markov model for the English language built
  123.               from commonly-available texts, this wordlist provides a powerful
  124.               tool for attacking even full passphrases.
  125.  
  126.               A Unix password dictionary is available from ftp.spc.edu as
  127.               .unix/password-dictionary.txt.
  128.  
  129.               Grady Ward <grady@netcom.com> has collected very large
  130.               collections of words, phrases, and other items suitable for
  131.               dictionary attacks on cryptosystems.  Even the NSA has used his
  132.               lists in their work.
  133.  
  134.  
  135. Other Software
  136. --------------
  137.  
  138. There are a small number of other programs available which claim to provide
  139. disk security of the kind provided by SFS.  However by and large these tend to
  140. use badly or incorrectly implemented algorithms, or algorithms which are known
  141. to offer very little security.  One such example is Norton's Diskreet, which
  142. encrypts disks using either a fast proprietary cipher or the US Data Encryption
  143. Standard (DES).  The fast proprietary cipher is very simple to break, and
  144. offers protection only against a casual browser.  Certainly anyone with any
  145. programming skill won't be stopped for long by a system as simple as this.
  146.  
  147. The more secure DES algorithm is also available in Diskreet, but there are
  148. quite a number of implementation errors which greatly reduce the security it
  149. should provide.  Although accepting a password of up to 40 characters, it then
  150. converts this to uppercase-only characters and then reduces the total size to 8
  151. characters of which only a small portion are used for the encryption itself.
  152. This leads to a huge reduction in the number of possible encryption keys, so
  153. that not only are there a finite (and rather small) total number of possible
  154. passwords, there are also a large number of equivalent keys, any of which will
  155. decrypt a file (for example a file encrypted with the key 'xxxxxx' can be
  156. decrypted with 'xxxxxx', 'xxxxyy', 'yyyyxx', and a large collection of other
  157. keys, too many to list here).
  158.  
  159. These fatal flaws mean that a fast dictionary-based attack can be used to check
  160. virtually all possible passwords in a matter of hours in a standard PC.  In
  161. addition the CBC (cipher block chaining) encryption mode used employs a known,
  162. fixed initialisation vector (IV), which means that data patterns on the
  163. encrypted disk are not hidden by the encryption.  Using these two
  164. implementation errors, a program can be constructed which will examine a
  165. Diskreet-encrypted disk and produce the password used to encrypt it (or at
  166. least one of the many, many passwords capable of decrypting it) within moments.
  167.  
  168. These problems are in fact explicitly warned against in any of the documents
  169. covering DES and its modes of operation, such as ISO Standards 10116 and
  170. 10126-2, US Government FIPS Publication 81, or basic texts like Dennings
  171. "Cryptography and Data Security".  It appears that the authors of Diskreet
  172. never even bothered to read any of the standard texts on encryption to make
  173. sure they were doing things right.  In addition the Diskreet encryption code
  174. appears to be taken from a separate library rather than being written by the
  175. people who sell Diskreet, with implementation errors in both the encryption
  176. code and the rest of Diskreet.
  177.  
  178. The DES routines used in Da Vinci, a popular groupware product, are similarly
  179. poorly implemented.  Not only is an 8-character password used directly as the
  180. DES key, but the DES encryption method used is the electronic codebook (ECB)
  181. mode, whose use is warned against in even the most basic cryptography texts
  182. and, in a milder form, in various international encryption standards.  For
  183. example, Annex A.1 of ISO 10116:1991 states "The ECB mode is in general not
  184. recommended".  ISO 10126-2:1991 doesn't even mention ECB as being useful for
  185. message encryption.  The combination of Da Vinci's very regular file structure
  186. (which provides an attacker with a large amount of known data in very file),
  187. the weak ECB encryption mode, and the extremely limited password range, makes a
  188. precomputed dictionary attack (which involves a single lookup in a pre-set
  189. table of plaintext-ciphertext pairs) very easy.  As ECB mode has no pattern
  190. hiding ability whatsoever, all that is necessary is to encrypt a common pattern
  191. (such as a string of spaces) with all possible dictionary password values, and
  192. sort and store the result in a table.  Any password in the dictionary can then
  193. be broken just as fast as the value can be read out of the table.
  194.  
  195. PC Tools is another example of a software package which offers highly insecure
  196. encryption.  The DES implementation used in this package has had the number of
  197. rounds reduced from the normal 16 to a mere 2, making it trivial to break on
  198. any cheap personal computer.  This very weak implementation is distributed
  199. despite a wide body of research which documents just how insecure 2-round DES
  200. really is.
  201.  
  202. Even a correctly-implemented and applied DES encryption system offers only
  203. marginal security against a determined attacker.  It has long been rumoured
  204. that certain government agencies and large corporations (and, no doubt,
  205. criminal organizations) possessed specialized hardware which allowed them to
  206. break the DES encryption.  However only in August of 1993 have complete
  207. constructional details for such a device been published.  This device, for
  208. which the budget version can be built for around $100,000, can find a DES key
  209. in 3.5 hours for the somewhat more ambitious $1 million version (the budget
  210. version takes 1 1/2 days to perform the same task). The speed of this device
  211. scales linearly with cost, so that the time taken can be reduced to minutes or
  212. even seconds if enough money is invested.  This is a one-off cost, and once a
  213. DES-breaking machine of this type is built it can sit there day and night
  214. churning out a new DES key every few minutes, hours, or days (depending on the
  215. budget of the attacker).
  216.  
  217. In the 1980's, the East German company Robotron manufactured hundreds of
  218. thousands of DES chips for the former Soviet Union.  This means one of two
  219. things: Either the Soviet Union used the chips to build a DES cracker, or they
  220. used DES to encrypt their own communications, which means that the NSA built
  221. one.
  222.  
  223. The only way around the problem of fast DES crackers is to run DES more than
  224. once over the data to be encrypted, using so-called triple DES (using DES twice
  225. is as easy to attack as single DES, so in practice three iterations must be
  226. used).  DES is inherently slow.  Triple DES is three times as slow.  A hard
  227. drive which performs like a large-capacity floppy drive may give users a sense
  228. of security, but won't do much for their patience.
  229.  
  230. The continued use of DES, mainly in the US, has been more due to a lack of any
  231. replacement than to an ongoing belief in its security.  The National Bureau of
  232. Standards (now National Institute of Standards and Technology) has only
  233. relucatantly re-certified DES for further use every five years.  Interestingly
  234. enough, the Australian government, which recently developed its own replacement
  235. for DES called SENECA, now rates DES as being "inappropriate for protecting
  236. government and privacy information" (this includes things like taxation
  237. information and social security and other personal data).  Now that an
  238. alternative is available, the Australian government seems unwilling to even
  239. certify DES for information given under an "in confidence" classification,
  240. which is a relatively low security rating.
  241.  
  242. Finally, the add-on "encryption" capabilities offered by general software
  243. packages are usually laughable.  Various programs exist which will
  244. automatically break the "encryption" offered by software such as Arc, Arj,
  245. Lotus 123, Lotus Symphony, Microsoft Excel, Microsoft Word, Paradox, Pkzip 1.x,
  246. the "improved encryption" in Pkzip 2.x, Quattro Pro, Unix crypt(1), Wordperfect
  247. 5.x and ealier, the "improved" encryption in Wordperfect 6.x, and many others.
  248. Indeed, these systems are often so simple to break that at least one package
  249. which does so adds several delay loops simply to make it look as if there were
  250. actually some work involved in the process. Although the manuals for these
  251. programs make claims such as "If you forget the password, there is absolutely
  252. no way to retrieve the document", the "encryption" used can often be broken
  253. with such time-honoured tools as a piece of paper, a pencil, and a small amount
  254. of thought.  Some programs which offer "password protection security" don't
  255. even try to perform any encryption, but simply do a password check to allow
  256. access to the data.  Two examples of this are Stacker and Fastback, both of
  257. which can either have their code patched or have a few bytes of data changed to
  258. ignore any password check before granting access to data.
  259.  
  260.  
  261. Data Security
  262. -------------
  263.  
  264. This section presents an overview of a range of security problems which are, in
  265. general, outside the reach of SFS.  These include relatively simple problems
  266. such as not-quite-deleted files and general computer security, through to
  267. sophisticated electronic monitoring and surveillance of a location in order to
  268. recover confidential data or encryption keys.  The coverage is by no means
  269. complete, and anyone seriously concerned about the possibility of such an
  270. attack should consult a qualified security expert for further advice.
  271.  
  272.  
  273. Information Leakage
  274.  
  275. There are several ways in which information can leak from an encrypted SFS
  276. volume onto other media.  The simplest kind is in the form of temporary files
  277. maintained by application software and operating systems, which are usually
  278. stored in a specific location and which, when recovered, may contain file
  279. fragments or entire files from an encrypted volume.  This is true not only for
  280. the traditional word processors, spreadsheets, editors, graphics packages, and
  281. so on which create temporary files on disk in which to save data, but also for
  282. operating systems such as OS/2, Windows NT, and Unix, which reserve a special
  283. area of a disk to store data which is swapped in and out of memory when more
  284. room is needed.
  285.  
  286. This information is usually deleted by the application after use, so that the
  287. user isn't even aware that it exists.  Unfortunately "deletion" usually
  288. consists of setting a flag which indicates that the file has been deleted,
  289. rather than overwriting the data in any secure way.  Any information which is
  290. "deleted" in this manner can be trivially recovered using a wide variety of
  291. tools.  In the case of a swap file there is no explicit deletion as the swap
  292. area is invisible to the user anyway. In a lightly-loaded system, data may
  293. linger in a swap area for a considerable amount of time.
  294.  
  295. The only real solution to this is to redirect all temporary files and swap
  296. files either to an encryption volume or to a RAM disk whose contents will be
  297. lost when power is removed.  Most programs allow this redirection, either as
  298. part of the program configuration options or by setting the TMP or TEMP
  299. environment variables to point to the encrypted volume or RAM disk.
  300.  
  301. Unfortunately moving the swap area and temporary files to an encrypted volume
  302. results in a slowdown in speed as all data must now be encrypted.  One of the
  303. basic premises behind swapping data to disk is that very fast disk access is
  304. available.  By slowing down the speed of swapping, the overall speed of the
  305. system (once swapping becomes necessary) is reduced.  However once a system
  306. starts swapping there is a significant slowdown anyway (with or without
  307. encryption), so the decision as to whether the swap file should be encrypted or
  308. not is left to the individual user.
  309.  
  310. The other major form of information leakage with encrypted volumes is when
  311. backing up encrypted data.  Currently there is no generally available secure
  312. backup software (the few applications which offer "security" features are
  313. ridiculously easy to circumvent), so that all data stored on an encrypted
  314. volume will be backed up in unencrypted form.  Like the decision on where to
  315. store temporary data and swap files, this is a tradeoff between security and
  316. convenience.  If it were possible to back up an encrypted volume in its
  317. encrypted form, the entire volume would have to be backed up as one solid block
  318. every time a backup was made.  This could mean a daily five-hundred-megabyte
  319. backup instead of only the half megabyte which has changed recently.
  320. Incremental backups would be impossible.  Backing up or restoring individual
  321. files would be impossible.  Any data loss or errors in the middle of a large
  322. encrypted block could be catastrophic (in fact the encryption method used in
  323. SFS has been carefully selected to ensure that even a single encrypted data bit
  324. changed by an attacker will be noticeable when the data is decrypted[1]).
  325.  
  326. Since SFS volumes in their encrypted form are usually invisible to the
  327. operating system anyway, the only way in which an encrypted volume can be
  328. backed up is by accessing it through the SFS driver, which means the data is
  329. stored in its unencrypted form.  This has the advantage of allowing standard
  330. backup software and schedules to be used, and the disadvantage of making the
  331. unencrypted data available to anyone who has access to the backups.  User
  332. discretion is advised.
  333.  
  334. If it is absolutely essential that backups be encrypted, and the time (and
  335. storage space) is available to back up an entire encrypted volume, then the
  336. Rawdisk 1.1 device driver written by Juergen Prang
  337. <prang@du9ds4.fb9dv.uni-duisburg.de> may be used to make the entire encrypted
  338. SFS volume appear as a file on a DOS drive which can be backed up using
  339. standard DOS backup software.  The instructions which come with Rawdisk give
  340. details on setting the driver up to allow non-DOS volumes to be backed up as
  341. standard DOS drives.  The SFS volume will appear as a single enormous file
  342. RAWDISK.DAT which entirely fills the DOS volume.
  343.  
  344. Footnote [1]: This is not a serious limitation, since it will only affect
  345.               deliberate changes in the data.  Any accidental corruption due to
  346.               disk errors will result in the drive hardware reporting the whole
  347.               sector the data is on as being unreadable.  If the data is
  348.               deliberately changed, the sector will be readable without errors,
  349.               but won't be able to be decrypted.
  350.  
  351.  
  352. Eavesdropping
  353.  
  354. The simplest form of eavesdropping consists of directly overwiewing the system
  355. on which confidential data is being processed.  The easiest defence is to
  356. ensure that no direct line-of-sight path exists from devices such as computer
  357. monitors and printers to any location from which an eavesdropper can view the
  358. equipment in question.  Copying of documents and the contents of computer
  359. monitors is generally possible at up to around 100 metres (300 feet) with
  360. relatively unsophisticated equipment, but is technically possible at greater
  361. distances.  The possibility of monitoring from locations such as
  362. office-corridor windows and nearby rooms should also be considered.  This
  363. problem is particularly acute in open-plan offices and homes.
  364.  
  365. The next simplest form of eavesdropping is remote eavesdropping, which does not
  366. require access to the building but uses techniques for information collection
  367. at a distance.  The techniques used include taking advantage of open windows or
  368. other noise conveying ducts such as air conditioning and chimneys, using
  369. long-range directional microphones, and using equipment capable of sensing
  370. vibrations from surfaces such as windows which are modulated by sound from the
  371. room they enclose.  By recording the sound of keystrokes when a password or
  372. sensitive data is entered, an attacker can later recreate the password or data,
  373. given either access to the keyboard itself or enough recorded keystrokes to
  374. reconstruct the individual key sound patterns.  Similar attacks are possible
  375. with some output devices such as impact printers.
  376.  
  377. Another form of eavesdropping involves the exploitation of existing equipment
  378. such as telephones and intercoms for audio monitoring purposes.  In general any
  379. device which handles audio signals and which can allow speech or other sounds
  380. to be transmitted from the place of interest, which can be modified to perform
  381. this task, or which can be used as a host to conceal a monitoring device and
  382. provide power and possibly microphone and transmission capabilites to it (such
  383. as, for example, a radio) can be the target for an attacker.  These devices can
  384. include closed-circuit television systems (which can allow direct overviewing
  385. of confidential information displayed on monitors and printers), office
  386. communication systems such as public address systems, telephones, and intercoms
  387. (which can either be used directly or modified to transmit sound from the
  388. location to be monitored), radios and televisions (which can be easily adapted
  389. to act as transmitters and which already contain power supplies, speakers (to
  390. act as microphones), and antennae), and general electrical and electronic
  391. equipment which can harbour a range of electronic eavesdropping devices and
  392. feed them with their own power.
  393.  
  394. Another eavesdropping possibility is the recovery of information from hardcopy
  395. and printing equipment.  The simplest form of this consists of searching
  396. through discarded printouts and other rubbish for information.  Even shredding
  397. a document offers only momentary protection against a determined enough
  398. attacker.  The recovery of text from the one-pass ribbon used in high-quality
  399. impact printers is trivial.  Recovery of text from multipass ribbons is also
  400. possible, albeit with somewhat more difficulty.  Recovery of the last few pages
  401. printed on a laser printer may also be possible.
  402.  
  403. Possibly the ultimate form of eavesdropping currently available, usually
  404. referred to as TEMPEST (or occasionally van Eck) monitoring, consists of
  405. monitoring the signals generated by all electrically-powered equipment.  These
  406. signals can be radiated in the same way as standard radio and television
  407. transmissions, or conducted along wiring or other metal work.  Some of these
  408. signals will be related to information being processed by the equipment, and
  409. can be easily intercepted (even at a significant distance) and used to
  410. reconstruct the information in question.  TEMPEST monitoring is usually
  411. relatively expensive in resources, difficult to mount, and unpredictable in
  412. outcome.  It is most likely to be carried out where other methods of
  413. eavesdropping are impractical and where general security measures are effective
  414. in stopping monitoring.  However, once in place, the amount of information
  415. available through this form of eavesdropping is immense.  In general it allows
  416. the almost complete recovery of all data being processed by a certain device
  417. such as a monitor or printer, almost undetectably, and over a long period of
  418. time.  Protection against TEMPEST monitoring is difficult and expensive, and is
  419. best left to computer security experts.
  420.  
  421.  
  422. Trojan Horses
  423.  
  424. It may be possible for an attacker to replace the SFS software with a copy
  425. which seems to be identical but which has major weaknesses in it which make an
  426. attack much easier, for example by using only a few characters of the password
  427. to encrypt the disk.  The least likely target is mksfs, since changing the way
  428. this operates would require a similar change to mountsfs and the SFS driver
  429. which would be easily detectable by comparing them with and independant,
  430. original copy.  Since a changed mksfs would require the long-term use of a
  431. similarly changed mountsfs and driver, the changes of detection are greatly
  432. increased.
  433.  
  434. A much more subtle attack involves changing mountsfs.  By substituting a
  435. version which saves the user's password or encryption key to an unused portion
  436. of the disk and then replaces itself with an unmodified, original copy, an
  437. attacker can return at their leisure and read the password or key off the disk,
  438. with the user none the wiser that their encryption key has been compromised.
  439. The SFS driver may be modified to do this as well, although the task is slighly
  440. more difficult than changing mountsfs.
  441.  
  442. Detecting this type of attack is very difficult, since although it is possible
  443. to use security software which detects changes, this itself might be modified
  444. to give a false reading.  Software which checks the checking software may in
  445. turn be modified, and so on ad infinitum.  In general someone who is determined
  446. enough can plant an undetectable trojan[1], although precautions like using
  447. modification-detection programs, keeping physically separate copies of the SFS
  448. software, and occasionally checking the installed versions against other,
  449. original copies, may help reduce the risk somewhat.  The eventual creation of a
  450. hardware SFS encryption card will reduce the risk further, although it is still
  451. possible for an attacker to substitute their own fake encryption card.
  452.  
  453. Another possibility is the creation of a program unrealted to SFS which
  454. monitors the BIOS character write routines for the printing of the password
  455. prompt, or video RAM for the appearance of the prompt, or the BIOS keyboard
  456. handler, or any number of other possibilities, and then reads the password as
  457. it is typed in.  This is a generic attack against all types of encryption
  458. software, and doesn't rely on a compromised copy of the software itself.  The
  459. only real way to defeat this is to use custom hardware which performs its task
  460. before any user software has time to run, such as the hardware SFS version
  461. currently under development.
  462.  
  463. Footnote [1]: An attacker could employ, for example, what David Farber has
  464.               described as "supplemental functionality in the keyboard driver".
  465.  
  466.  
  467. Dangers of Encryption
  468.  
  469. The use of very secure encryption is not without its downsides, however.
  470. Making the data completely inaccessible to anyone but the holder of the correct
  471. password can be hazardous if the data being protected consists of essential
  472. information such as the business records for a company which are needed in its
  473. day-to-day operation.  If the holder of the encryption password is killed in an
  474. accident (or even just rendered unconscious for a time), the potential complete
  475. loss of all business records is a serious concern.
  476.  
  477. Another problem is the question of who the holder of the password(s) should be.
  478. If the system administrator at a particular site routinely encrypts all the
  479. data held there for security purposes, then later access to the entire
  480. encrypted dataset is dependant on the administrator, who may forget the
  481. password, or die suddenly, or move on to another job and have little incentive
  482. to inform their previous employer of the encryption password (for example if
  483. they were fired from the previous job).  Although there are (as yet) no known
  484. cases of this happening, it could occur that the ex-administrator has forgotten
  485. the password used at his previous place of employment and might require a
  486. small, five-figure consideration to help jog his memory.  The difficulty in
  487. prosecuting such a case would be rather high, as proving that the encryption
  488. system wasn't really installed in good faith by the well-intentioned
  489. administrator to protect the company data and that the password wasn't
  490. genuinely forgotten would be well nigh impossible.
  491.  
  492.  
  493. Politics
  494. --------
  495.  
  496. Many governments throughout the world have an unofficial policy on cryptography
  497. which is to reserve all knowledge and use of encryption to the government in
  498. general and the elite in particular.  This means that encryption is to be used
  499. firstly (in the form of restrictions on its use) for intelligence-gathering,
  500. and secondly for protecting the secret communications of the government.
  501. Therefore the government uses encryption to protect its own dealings, but
  502. denies its citizens the right to use it to protect their own privacy, and
  503. denies companies the right to use it to protect their business data.
  504.  
  505. This policy is enforced in many ways.  In the US it is mainly through the use
  506. of the ITAR, the International Traffic in Arms Regulations, a law dating back
  507. to the second world war and passed with no public debate.  This defines all
  508. encryption material (hardware and software) as "munitions", subject to special
  509. governmental control.  These "munitions" in fact have no violent uses (unless,
  510. say, you tried beating someone to death with a box of disks).  Their only
  511. possible use is to protect your personal privacy, and the privacy of your
  512. business data.
  513.  
  514. In limiting the use (and export) of encryption technology, the US (and many
  515. other countries which follow the lead of the US) are not only denying their
  516. citizens the means to ensure the privacy of personal information stored on
  517. computer, they are also placing businesses at risk.  With no easy way to
  518. protect their data, companies are losing billions of dollars a year to
  519. industrial espionage which even a simple measure like SFS would help to reduce.
  520. Some real-life examples of what the lack of secure encryption can do:
  521.  
  522.     - The head of the French DGSE (Direction Generale de la Securite
  523.       Exterieure) secret service has publicly boasted that his organisation,
  524.       through industrial espionage, helped French companies acquire over a
  525.       billion dollars worth of business deals from foreign competitors[1][2].
  526.  
  527.     - A US company was being consistently underbid by a Japanese competitor
  528.       which was intercepting their electronic traffic.  When they started
  529.       encrypting their messages, the underbidding stopped.  A few days later
  530.       they were requested by the US government to stop using encryption in
  531.       their traffic[3].
  532.  
  533.     - A New Zealand computer dealer acquired 90 used disks which turned out to
  534.       contain sensitive financial records from a large bank.  The evening after
  535.       he turned them over to the bank (for a $15,000 cash "finders fee") he was
  536.       killed in a road accident.  The finders fee was never recovered [4].
  537.  
  538.       Despite this major security hole, the bank wouldn't learn from their
  539.       mistakes.  A few weeks later a large networked disk drive originally used
  540.       by them was supplied to another company as a supposedly "new" replacement
  541.       for a drive which had died.  This drive was found to contain the complete
  542.       financial records from one of their branches.  Not wanting to be scraped
  543.       off the side of the road one night, the system manager decided to erase
  544.       the contents of the disk[5].
  545.  
  546.       It isn't known how many more of their confidential financial records this
  547.       bank has handed out to the public over the years.
  548.  
  549. In the latter case the lack of encryption not only had the potential to cause
  550. serious financial harm to the bank involved but resulted in the death of the
  551. main player.  The use of a program like SFS would have made the contents of the
  552. disks unreadable to anyone but the bank.
  553.  
  554. In 1991 the US Justice Department tried to introduce legislation that would
  555. require all US digital communications systems to be reengineered (at enormous
  556. cost) to support monitoring of message traffic by the FBI.  This measure was
  557. never passed into law.  The next year the FBI tried to introduce a similar
  558. measure, but could find no-one willing to back the bill.
  559.  
  560. In April 1993, the US government announced a piece of hardware called the
  561. Clipper Chip.  They proposed that this device, whose details are classified and
  562. which contains a self-destruct mechanism which is activated if attempts are
  563. made to examine it too closely, be built into all telephones.  Each chip has a
  564. special serial number which identifies all communications carried out with that
  565. phone.  At the beginning of each transmission, telephones equipped with a
  566. Clipper Chip negotiate a connection which involves sending identifying
  567. information across the phone network, and setting up a common key to use for
  568. encrypting the conversation.
  569.  
  570. Built into this setup is a special back door which allows the government, and
  571. anyone who works for the government, and anyone who has a friend who works for
  572. the government, and anyone with enough money or force to bribe or coerce the
  573. aforementioned people, to monitor the conversation.  The job is made much
  574. easier by the extra identification information which the Clipper Chip attaches
  575. to the data stream.  The Clipper Chip allows monitoring on a scale even George
  576. Orwell couldn't have imagined when he wrote his novel "1984"[6].
  577.  
  578. A somewhat less blatant attempt to bypass communications privacy is gradually
  579. appearing in the rest of the world.  The GSM digital telephone system uses a
  580. special encryption algorithm called A5X which is a modified form of a stronger
  581. system called A5.  A5X exists solely as a deliberately crippled A5, and is
  582. almost trivial to bypass for electronic monitoring purposes.  Although the
  583. details of A5 are classified "for national security purposes", various sources
  584. have commented that even the original unmodified A5 probably provides only
  585. limited security against a determined attack, and the actual implementation
  586. exhibits some fundamental flaws (such as a 3-hour key rollover) which can
  587. greatly aid an attacker.
  588.  
  589. It is against this worrying background that SFS was created.  Right from the
  590. start, the idea behind SFS was to provide the strongest possible cryptographic
  591. security.  No compromises were made, there are no back doors or weaknesses
  592. designed into the system, nor will there ever be the deliberate crippling of
  593. the system or undermining of its integrity which some organizations would like.
  594. The algorithms and methods used in SFS have been selected specifically for
  595. their acknowledged strength and general acceptance by the worldwide
  596. cryptographic community, and conform to a wide variety of national and
  597. international standards for secure encryption.  As new algorithms and
  598. cryptographic processes appear, SFS will be updated to always provide the best
  599. possible security available.
  600.  
  601. Footnote [1]  This was reported by cryptographer Martin Hellman at the 1993 RSA
  602.               Data Security conference on 14-15 January 1993.
  603.  
  604. Footnote [2]  Some quotes from FBI Director Louis Freeh from a talk given to
  605.               the Executives' Club of Chicago on 17 March 1994:
  606.  
  607.               "A nation's power is increasingly measured by economic prosperity
  608.                at home and competitiveness abroad.  And in some ways, the
  609.                United States is a sitting duck for countries and individuals
  610.                who want to take a short cut to power".
  611.  
  612.                [At least 20 nations are] "actively engaged in economic
  613.                espionage".
  614.  
  615.               "This kind of information [cost and price structure, research and
  616.                development results, marketing plans, bids and customer lists]
  617.                can be intercepted from fax and satellite communications.  It
  618.                can be monitored from cellular and microwave telephone links.
  619.                It can be retrieved from inadequately protected computer
  620.                systems".
  621.  
  622. Footnote [3]: Private communications from one of the people involved.
  623.  
  624. Footnote [4]: This event received nationwide TV, radio, and newspaper coverage
  625.               at the time.  For example, any New Zealand paper published on 7
  626.               September 1992 should provide more information.
  627.  
  628. Footnote [5]: Private communications from the system manager involved.
  629.  
  630. Footnote [6]: It has been claimed that the Clipper proposal is an example of
  631.               the government servicing the people in the sense of the term used
  632.               in the sentence "The farmer got a bull to service his cows".
  633.  
  634.  
  635. Security Analysis
  636. -----------------
  637.  
  638. This section attempts to analyse some of the possible failure modes of SFS and
  639. indicate which strategies have been used to minimise problems.
  640.  
  641.  
  642. Incorrect Encryption Algorithm Implementations
  643.  
  644. When implementing something as complex as most encryption algorithms, it is
  645. very simple to make a minor mistake which greatly weakens the implementation.
  646. It is a well-known fact that making even the smallest change to the DES
  647. algorithm reduces its strength considerably.  There is a body of test data
  648. available as US National Bureau of Standards (NBS) special publication 500-20
  649. which can be used to validate DES implementations.  Unfortunately the
  650. programmers who produce many commercial DES implementations either don't know
  651. it exists or have never bothered using it to verify their code (see the section
  652. "Other Software" above), leading to the distribution of programs which perform
  653. some sort of encryption which is probably quite close to DES but which
  654. nevertheless has none of the security of the real DES.
  655.  
  656. In order to avoid this problem, the SHS code used in SFS has a self-test
  657. feature which can be used to test conformance with the data given in Federal
  658. Information Processing Standards (FIPS) publication 180, which is the
  659. specification for the SHS algorithm.  This self-test can be invoked in the
  660. mksfs program by giving it the option `-t' for `test':
  661.  
  662.     mksfs -t
  663.  
  664. mountsfs and the SFS driver itself use exactly the same code, so testing it in
  665. mksfs is enough to ensure correctness of the other two programs.  The following
  666. tests can take a minute or so to run to completion.
  667.  
  668. The self-test, when run, produces the following output:
  669.  
  670.   Running SHS test 1 ... passed, result=0164B8A914CD2A5E74C4F7FF082C4D97F1EDF880
  671.   Running SHS test 2 ... passed, result=D2516EE1ACFA5BAF33DFC1C471E438449EF134C8
  672.   Running SHS test 3 ... passed, result=3232AFFA48628A26653B5AAA44541FD90D690603
  673.  
  674. The test values can be compared for correctness with the values given in
  675. Appendix 1 of the FIPS publication.  If any of the tests fail, mksfs will exit
  676. with an error message.  Otherwise it will perform a speed test and display a
  677. message along the lines of:
  678.  
  679.   Testing speed for 10MB data... done.  Time = 31 seconds, 323 kbytes/second
  680.  
  681.   All SHS tests passed
  682.  
  683. Note that the speed given in this test is only vaguely representative of the
  684. actual speed, as the test code used slows the implementation down somewhat.  In
  685. practice the overall speed should be higher than the figure given.
  686.  
  687.  
  688. Weak passwords
  689.  
  690. Despite the best efforts of security specialists to educate users about the
  691. need to chose good keys, people persist in using very weak passwords to protect
  692. critical data.  SFS attempts to ameliorate this problem by forcing a minimum
  693. key length of 10 characters and making a few simple checks for insecure
  694. passwords such as single words (since the number of words of length 10 or more
  695. characters is rather small, it would allow a very fast dictionary check on all
  696. possible values).  The checking is only rudimentary, but in combination with
  697. the minimum password length should succeed in weeding out most weak passwords.
  698.  
  699. Another possible option is to force a key to contain at least one punctuation
  700. character, or at least one digit as some Unix systems do.  Unfortunately this
  701. tends to lead people to simply append a single punctuation character or a fixed
  702. digit to the end of an existing key, with little increase in security.
  703.  
  704. More password issues are discussed in the section "The Care and Feeding of
  705. Passwords" above.
  706.  
  707.  
  708. Data left in program memory by SFS programs
  709.  
  710. Various SFS utilities make use of critical keying information which can be used
  711. to access an SFS volume.  Great care has been taken to ensure that all critical
  712. information stored by these programs is erased from memory at the earliest
  713. possible moment.  All encryption-related information is stored in static
  714. buffers which are accessed through pointers passed to various routines, and is
  715. overwritten as soon as it is no longer needed.  All programs take great care to
  716. acquire keying information from the user at the last possible moment, and
  717. destroy this information as soon as either the disk volume has been encrypted
  718. or the keying information has been passed to the SFS driver.  In addition, they
  719. install default exit handlers on startup which systematically erase all data
  720. areas used by the program, both for normal exits and for error or
  721. special-condition exits such as the user interrupting the programs execution.
  722.  
  723.  
  724. Data left in program memory by the SFS driver
  725.  
  726. The SFS driver, in order to transparently encrypt and decrypt a volume, must
  727. store at all times the keying information needed to encrypt and decrypt the
  728. volume.  It is essential that this information be destroyed as soon as the
  729. encrypted volume is unmounted.  SFS does this by erasing all encryption-related
  730. information held by the driver as soon as it receives an unmount command.  In
  731. addition, the driver's use of a unique disk key for each disk ensures that even
  732. if a complete running SFS system is captured by an opponent, only the key for
  733. the volume currently mounted will be compromised, even if several volumes are
  734. encrypted with the same user password (see the section "Controlled Disclosure
  735. of Encrypted Information" below for more details on this).
  736.  
  737.  
  738. Data left in system buffers by mksfs
  739.  
  740. mksfs must, when encrypting a volume, read and write data via standard system
  741. disk routines.  This data, consisting of raw disk sectors in either plaintext
  742. or encrypted form, can linger inside system buffers and operating system or
  743. hard disk caches for some time afterwards.  However since none of the
  744. information is critical (the plaintext was available anyway moments before
  745. mksfs was run, and at worst knowledge of the plaintext form of a disk sector
  746. leads to a known plaintext attack, which is possible anyway with the highly
  747. regular disk layout used by most operating systems), and since accessing any of
  748. this information is highly nontrivial, this is not regarded as a weakness.
  749.  
  750.  
  751. Data left in system buffers by mountsfs
  752.  
  753. As part of its normal operation, mountsfs must pass certain keying information
  754. to the SFS driver through a DOS system call.  DOS itself does not copy the
  755. information, but simply passes a pointer to it to the SFS driver.  After the
  756. driver has been initialised, mountsfs destroys the information as outlined
  757. above.  This is the only time any keying information is passed outside the
  758. control of mountsfs, and the value is only passed by reference.
  759.  
  760.  
  761. Data left in system buffers by the SFS driver
  762.  
  763. Like mksfs, the SFS driver reads and writes data via standard system disk
  764. routines.  This data, consisting of raw disk sectors in either plaintext or
  765. encrypted form, can linger inside system buffers and operating system or hard
  766. disk caches for some time afterwards.  Once the encrypted volume is unmounted,
  767. it is essential that any plaintext information still held in system buffers be
  768. destroyed.
  769.  
  770. In order to accomplish this, the SFS driver, when issued with an unmount
  771. command, performs two actions intended to destroy any buffered information.
  772. First, it issues a cache flush command followed by a cache reset command to any
  773. DOS drive cacheing software it recognizes, such as older versions of
  774. Microsoft's SmartDrive (with IOCTL commands), newer versions of SmartDrive
  775. (version 4.0 and up), the PCTools 5.x cache, Central Point Software's PC-Cache
  776. 6.0 and up, the more recent PC-Cache 8.x, Norton Utilities' NCache-F, NCache-S,
  777. and the newer NCache 6.0 and up, the Super PC-Kwik cache 3.0 and up, and
  778. Qualitas' QCache 4.0 and up.  Some other cacheing software can be detected but
  779. doesn't support external cache flushing.  This step is handled by mountsfs
  780. rather than the driver due to the rather complex nature of the procedures
  781. necessary to handle the large variety of cacheing software, and the fact that
  782. most cacheing software can't be accessed from a device drvier.
  783.  
  784. After this the SFS driver itself issues a disk reset command which has the
  785. effect of flushing all buffered and cached data scheduled to be written to a
  786. disk, and of marking those cache and buffer entries as being available for
  787. immediate use.  In addition to the explicit flushing performed by the mountsfs
  788. program, many cacheing programs will recognise this as a signal to flush their
  789. internal buffers (quite apart from the automatic flushing performed by the
  790. operating system and the drive controller).
  791.  
  792. Any subsequent disk accesses will therefore overwrite any data still held in
  793. the cache and system buffers.  While this does not provide a complete guarantee
  794. that the data has gone (some software disk caches will only support a cache
  795. flush, not a complete cache reset), it is the best which can be achieved
  796. without using highly hardware and system-specific code.
  797.  
  798.  
  799. SFS volumes left mounted
  800.  
  801. It is possible that an SFS volume may be unintentionally left mounted on an
  802. unattended system, allowing free access to both the in-memory keying
  803. information and the encrypted volume.  In order to lessen this problem
  804. somewhat, a fast-unmount hotkey has been incorporated into the SFS driver which
  805. allows an unmount command to be issued instantly from the keyboard (see the
  806. sections "Mounting an SFS Volume" and "Advanced SFS Driver Options" above).
  807. The ease of use of this command (a single keystroke) is intended to encourage
  808. the unmounting of encrypted volumes as soon as they are no longer needed,
  809. rather than whenever the system is next powered down.
  810.  
  811. As an extra precaution, the driver's use of a unique disk key for each disk
  812. ensures that even if a complete running SFS system with an encrypted volume
  813. still mounted is captured by an opponent, only the key for the volume currently
  814. mounted will be compromised, even if several volumes are encrypted with the
  815. same user password (see the section "Controlled Disclosure of Encrypted
  816. Information" below for more details on this).
  817.  
  818. Finally, a facility for an automatic timed unmount for volumes left mounted is
  819. provided, so that volumes mistakenly left mounted while the system is
  820. unattended may be automatically unmounted after a given period of time.  This
  821. ensures that, when the inevitable distractions occur, encrypted volumes are
  822. safely unmounted at some point rather than being left indefinitely accessible
  823. to anyone with access to the system.
  824.  
  825.  
  826. Controlled disclosure of encrypted information
  827.  
  828. To date there are no known laws which can be used to enforce disclosure of
  829. encrypted information, a field which is usually covered by safeguards against
  830. self-incrimination.  However there have been moves in both the US and the UK to
  831. pass legislation which would compromise the integrity of encrypted information,
  832. or which would remove protection against self-incrimination.  In either case
  833. this would allow agencies to compel users of cryptographic software to reveal
  834. the very information they are trying to protect, often without the users even
  835. being aware that their privacy is being compromised.
  836.  
  837. The approach taken in the US, in the form of the Clipper initiative, is to have
  838. all encryption keys held by the government.  If disclosure of the information
  839. is required, the key is retrieved from storage and used to decrypt the
  840. information.  A side effect of this is that any data which has ever encrypted
  841. with the key, and any data which will ever be encrypted in the future, has now
  842. been rendered unsafe.  This system is best viewed as uncontrolled disclosure.
  843.  
  844. SFS includes a built-in mechanism for controlled disclosure so that, if
  845. disclosure is ever required by law, only the information for which access is
  846. authorized may be revealed.  All other encrypted data remains as secure as it
  847. was previously.
  848.  
  849. This is achieved by encrypting each disk volume with a unique disk key which is
  850. completely unrelated to the users passphrase.  When the passphrase is entered,
  851. it is transformed by iterating a one-way hash function over it several hundred
  852. times to create an intermediate key which is used to decrypt the disk key
  853. itself.  The disk volume is then en/decrypted with the disk key rather than the
  854. unmodified encyrption key supplied by the user.  There is no correlation
  855. between the user/intermediate key and the disk key
  856.  
  857. If disclosure of the encrypted information is required, the disk key can be
  858. revealed without compromising the security of the user key (since it is
  859. unrelated to the user key), or the integrity of any other data encrypted with
  860. the user key (since the disk key is unique for each disk volume, so that
  861. knowledge of a particular disk key allows only the one volume it corresponds to
  862. to be decrypted).
  863.  
  864. The controlled disclosure option is handled by the two mountsfs options `-d'
  865. and `-c'.  The `-d' option will disclose the unique key for a given disk
  866. volume, and the `-c' option will accept this key instead of the usual password.
  867. For example to disclose the disk key for the SFS volume "Data", the command
  868. would be:
  869.  
  870.   mountsfs -d vol=data
  871.  
  872. mountsfs will then ask for the password in the usual manner, and then prompt:
  873.  
  874.   You are about to disclose the encryption key for this SFS volume.
  875.   Are you sure you want to do this [y/n]
  876.  
  877. At this point a response of 'Y' will continue and a response of 'N' will exit
  878. the program without disclosing the disk key.  A response of 'Y' will print the
  879. disk key in the following format:
  880.  
  881.   Disk key is
  882.  
  883.       2D 96 B1 06 6D E8 30 21 D5 DB 1B CC 3E 0E C7 CF D6 D1 0C 97 75 DC
  884.       06 74 BC 2F E6 A0 3C 56 80 5F 0D 30 DA 54 D3 0D 28 F3 14 DE 79 67
  885.       6E 1A 75 DC 33 87 86 29 BA A5 B1 64 5B 79 67 8C 8A 1B D1 27 5B 79
  886.       73 6B 45 7B DA 54 43 6C C1 AB 06 67 7E 94 86 F2 50 22 09 8D 21 D5
  887.       E7 3A 80 5F 0D 30 DA 54 D3 0D 28 FF 6D E8 30 21 33 87 86 29 C0 ED
  888.       4A 22 96 B1 06 6D E8 30 21 D5 1C 2D E6 A0 3C 56 DA 54 43 6C 56 80
  889.  
  890. This is the unique key needed to access the particular encrypted volume.
  891.  
  892. To use this key instead of the usual one with mountsfs, the command would be:
  893.  
  894.   mountsfs -c vol=data
  895.  
  896. mountsfs will then ask for this disk key instead of the usual password:
  897.  
  898.   Please enter 264-digit disk key, [ESC] to exit:
  899.  
  900. At this point the disk key should be entered.  mountsfs will automatically
  901. format the data as it is entered to conform to the above layout.  The ESC key
  902. can be used at any point to exit the process.
  903.  
  904. Once the key has been entered, the program will perform a validity check on the
  905. key.  If this test fails, mountsfs will display the message:
  906.  
  907.   Error: Incorrect disk key entered
  908.  
  909. and exit.  Otherwise it will mount the volume as usual.  Since each volume has
  910. its own unique disk key, revealing the key for one volume gives access to that
  911. volume and no others.  Even if 20 volumes are all encrypted with the same user
  912. password, only one volume can be accessed using a given disk key.
  913.  
  914.  
  915. Password Lifetimes and Scope
  916.  
  917. An SFS password which is used over a long period of time makes a very tempting
  918. target for an attacker.  The longer a particular password is used, the greater
  919. the chance that it is compromised.  A password used for a year has a far
  920. greater chance of being compromised than one used for a day.  If a password is
  921. used for a long period of time, the temptation for an attacker to spend the
  922. effort necessary to break it is far greater than if the password is only a
  923. short-term one.
  924.  
  925. The scope of a password is also important.  If a password is used to encrypt a
  926. single drive containing business correspondence, it's compromise is only mildly
  927. serious.  If it is employed to protect dozens of disk volumes or a large file
  928. server holding considerable amounts of confidential information, the compromise
  929. of the password could be devastating.  Again, the temptation to attack the
  930. master password for an entire file server is far greater than for the password
  931. protecting data contained on a single floppy disk.
  932.  
  933. SFS attacks this problem in two ways.  First, it uses unique disk keys to
  934. protect each SFS volume.  The disk key is a 1024-bit cryptographically strong
  935. random key generated from nondeterministic values acquired from system
  936. hardware, system software, and user input (see the subsection "Generating
  937. Random Numbers" below).  The data on each disk volume is encrypted using this
  938. unique disk key, which is stored in encrypted form in the SFS volume header
  939. (this works somewhat like session keys in PEM or PGP, except that a
  940. conventional-key algorithm is used instead of a public-key one).  To access the
  941. disk, the encrypted disk key is first decrypted with the user password, and the
  942. disk key itself is used to access the disk.  This denies an attacker any known
  943. plaintext to work with (as the plaintext consists of the random disk key).  To
  944. check whether a given password is valid, an attacker must use it to decrypt the
  945. disk key, rekey the encryption system with the decrypted disk key, and try to
  946. decrypt the disk data.  Only then will they know that whether their password
  947. guess was correct or not.  This moves the target of an attack from a (possibly
  948. simple) user password to a 1024-bit random disk key.
  949.  
  950. The other way in which SFS tries to ameliorate the problem of password
  951. lifetimes and scope is by making the changing of a password a very simple
  952. operation.  Since the only thing which needs to be changed when a password
  953. change is made is the encrypted disk key, the entire password change operation
  954. can be made in a matter of seconds, rather than the many minutes it would take
  955. to decrypt and re-encrypt an entire disk.  It is hoped that the ease with which
  956. passwords can be changed will encourage the frequent changing of passwords by
  957. users.
  958.  
  959.  
  960. An Introduction to Encryption Systems
  961. -------------------------------------
  962.  
  963. For space reasons the following introduction to encryption systems is very
  964. brief.  Anyone requiring more in-depth coverage is urged to consult the texts
  965. mentioned in the references at the end of this document.
  966.  
  967. Encryption algorithms (ciphers) are generally one of two types, block ciphers
  968. and stream ciphers.  A block cipher takes a block of plaintext and converts the
  969. entire block into ciphertext.  A stream cipher takes a single bit or byte of
  970. plaintext at a time and converts it into ciphertext.  There also exist means of
  971. converting block ciphers to stream ciphers, and vice versa.  Usually a stream
  972. cipher is preferred, as it doesn't require data to be quantised to the block
  973. size of the cipher in use.  Unfortunately, stream ciphers, although more
  974. convenient, are usually harder to get right than block ciphers.  Many practical
  975. stream ciphers are in fact simply block ciphers pretending to be stream
  976. ciphers.
  977.  
  978. Virtually all good conventional-key ciphers are so-called product ciphers, in
  979. which several (relatively) weak transformations such as substitution,
  980. transposition, modular addition/multiplication, and linear transformation are
  981. iterated over a piece of data, gaining more and more strength with each
  982. iteration (usually referred to as a round).  These types of ciphers have been
  983. extensively studied and are reasonably well understood.  The following table
  984. compares the main parameters of several product ciphers.  Lucifer is the
  985. immediate precursor to the US Data Encryption Standard (DES).  Loki is a
  986. proposed alternative to DES.  FEAL is a fast block cipher designed in Japan.
  987. IDEA is a relatively new Swiss block cipher which has been proposed as a
  988. successor to DES and which has (so far) proven more resistant to attack then
  989. DES.  MDC/SHS is a cipher based on the SHS one-way hash function (more on this
  990. later).
  991.  
  992.    +-----------+------------+----------+-----------+---------------+
  993.    |  Cipher   | Block size | Key size | Number of | Complexity of |
  994.    |           |            |  (bits)  |   rounds  |  Best Attack  |
  995.    +-----------+------------+----------+-----------+---------------+
  996.    |  Lucifer  |    128     |    128   |     16    |     2^21      |
  997.    |    DES    |     64     |     56   |     16    |     2^43      |
  998.    |  Loki91   |     64     |     64   |     16    |     2^48      |
  999.    |  FEAL-8   |     64     |    128   |      8    |    10,000     |
  1000.    |   IDEA    |     64     |    128   |      8    |     2^128     |
  1001.    |  MDC/SHS  |    160     |    512   |     80    |     2^512     |
  1002.    +-----------+------------+----------+-----------+---------------+
  1003.  
  1004. The complexity of the best known attack is the number of operations necessary
  1005. to allow the cipher to be broken.  Note how the block size, key size, and
  1006. number of rounds don't necessarily give a good indication of how secure the
  1007. algorithm itself is.  Lucifer, although it has twice the block size and over
  1008. twice the key size of DES, is rather simple to break (the key size of DES is
  1009. discussed later on in the section on insecurities).  DES is the result of
  1010. several years of work improving on Lucifer.  FEAL has been continually changed
  1011. every year or so when the previous version was broken.  Due to this, current
  1012. versions are treated with some scepticism.  Both IDEA and MDC have so far
  1013. resisted all forms of attack, although recently a class of weak keys have been
  1014. discovered in IDEA (and a simple change in the algorithm will eliminate these
  1015. weak keys).  Note that in the case of the last two algorithms the given
  1016. complexity is for a brute-force attack (explained below), which is the most
  1017. pessimistic kind possible.  There may be much better attacks available,
  1018. although if anyone knows of any they're not saying anything.  Of the algorithms
  1019. listed above, DES has been attacked the hardest, and IDEA and MDC the least,
  1020. which may go some way to explaining the fact that brute force is the best known
  1021. attack.
  1022.  
  1023. There are a large number of modes of operation in which these block ciphers can
  1024. be used.  The simplest is the electronic codebook (ECB) mode, in which the data
  1025. to be encrypted is broken up into seperate subblocks which correspond to the
  1026. size of the block cipher being used, and each subblock is encrypted
  1027. individually.  Unfortunately ECB has a number of weaknesses (some of which are
  1028. outlined below), and would never be used in a well-designed cryptosystem.
  1029. Using P[] to denote a plaintext block, C[] to denote a ciphertext block, e() to
  1030. denote encryption, d() to denote decryption, and ^ for the exclusive-or
  1031. operation, ECB mode encryption can be given as:
  1032.  
  1033.     C[ n ] = e( P[ n ] )
  1034.  
  1035. with decryption being:
  1036.  
  1037.     P[ n ] = d( C[ n ] )
  1038.  
  1039. A better encryption mode is cipher block chaining (CBC), in which the first
  1040. data subblock is exclusive-ored with an initialization vector (IV) and then
  1041. encrypted.  The resulting ciphertext is exclusive-ored with the next data
  1042. subblock, and the result encrypted.  This process is repeated until all the
  1043. data has been encrypted.  Because the ciphertext form of each subblock is a
  1044. function of the IV and all preceding subblocks, many of the problems inherent
  1045. in the ECB encryption mode are avoided.  CBC-mode encryption is:
  1046.  
  1047.     C[ 1 ] = e( P[ 1 ] ^ IV )
  1048.     C[ n ] = e( P[ n ] ^ C[ n-1 ] )
  1049.  
  1050. and decryption is:
  1051.  
  1052.     P[ 1 ] = d( C[ 1 ] ) ^ IV
  1053.     P[ n ] = d( C[ n ] ) ^ C[ n-1 ]
  1054.  
  1055. Another encryption mode is cipher feedback (CFB), in which the IV is encrypted
  1056. and then exclusive-ored with the first data subblock to provide the ciphertext.
  1057. The resulting ciphertext is then encrypted and exclusive-ored with the next
  1058. data subblock to provide the next ciphertext block.  This process is repeated
  1059. until all the data has been encrypted.  Because the ciphertext form of each
  1060. subblock is a function of the IV and all preceding subblocks (as is also the
  1061. case for CBC-mode encryption), many of the problems inherent in the ECB
  1062. encryption mode are avoided.  CFB-mode encryption is:
  1063.  
  1064.     C[ 1 ] = P[ 1 ] ^ e( IV )
  1065.     C[ n ] = P[ n ] ^ e( C[ n-1 ] )
  1066.  
  1067. and decryption is:
  1068.  
  1069.     P[ 1 ] = C[ 1 ] ^ e( IV )
  1070.     P[ n ] = C[ n ] ^ e( C[ n-1 ] )
  1071.  
  1072. There are several other modes of operation which are not covered here.  More
  1073. details can be found in the texts given in the references.
  1074.  
  1075. One point worth noting is that by using a different IV for each message in CBC
  1076. and CFB mode, the ciphertext will be different each time, even if the same
  1077. piece of data is encrypted with the same key.  This can't be done in ECB mode,
  1078. and is one of its many weaknesses.
  1079.  
  1080. There are several standard types of attack which can be performed on a
  1081. cryptosystem.  The most restricted of these is a ciphertext-only attack, in
  1082. which the contents of the message are unknown.  This kind of attack virtually
  1083. never occurs, as there is always some regularity or known data in the message
  1084. which can be exploited by an attacker.
  1085.  
  1086. This leads to the next kind of attack, the known-plaintext attack.  In this
  1087. case some (or all) of the plaintext of the message is known.  This type of
  1088. attack is fairly easy to mount, since most data consists of well-known,
  1089. fixed-format messages containing standard headers, a fixed layout, or data
  1090. conforming to a certain probability distribution such as ASCII text.
  1091.  
  1092. Finally, in a chosen-plaintext attack the attacker is able to select plaintext
  1093. and obtain the corresponding ciphertext.  This attack is also moderately easy
  1094. to mount, since it simply involves fooling the victim into transmitting a
  1095. message or encrypting a piece of data chosen by the attacker.  This kind of
  1096. attack was used to help break the Japanese "Purple" cipher during WWII by
  1097. including in a news release a certain piece of information which it was known
  1098. the Japanese would encrypt and transmit to their superiors.
  1099.  
  1100. However attacks of this kind are usually entirely unnecessary.  Too many
  1101. cryptosystems in everyday use today are very easy to break, either because the
  1102. algorithms themselves are weak, because the implementations are incorrect, or
  1103. because the way they are used is incorrect.  Often amateurs think they can
  1104. design secure systems, and are not aware of what an expert cryptanalyst could
  1105. do.  Sometimes there is insufficient motivation for anybody to invest the work
  1106. needed to produce a secure system.  Many implementations contain flaws which
  1107. aren't immediately obvious to a non-expert.  Some of the possible problems
  1108. include:
  1109.  
  1110. - Use of easily-searched keyspaces.  Some algorithms depend for their security
  1111.   on the fact that a search of all possible encryption keys (a so-called brute
  1112.   force attack) would take too long to be practical.  Or at least, it took too
  1113.   long to be practical when the algorithm was designed.  The Unix password
  1114.   encryption algorithm is a prime example of this.  The DES key space is
  1115.   another example.  Recent research has indicated that the DES was not in fact
  1116.   weakened by having only 56 bits of key material (as has often been claimed),
  1117.   since the inherent strength of the algorithm itself only provides this many
  1118.   bits of security (that is, that increasing the key size would have no effect
  1119.   since other attacks which don't involve knowing the key can be used to break
  1120.   the encryption in far less than 2^56 operations).  The encryption used in the
  1121.   Pkzip archiver can usually be broken automatically in less time than it takes
  1122.   to type the password in for authorized access to the data since, although it
  1123.   allows longer keys than DES, it makes the check for valid decryption keys
  1124.   exceedingly easy for an attacker.
  1125.  
  1126. - Use of insecure algorithms designed by amateurs.  This covers the algorithms
  1127.   used in the majority of commercial database, spreadsheet, and wordprocessing
  1128.   programs such as Lotus 123, Lotus Symphony, Microsoft Excel, Microsoft Word,
  1129.   Paradox, Quattro Pro, WordPerfect, and many others.  These systems are so
  1130.   simple to break that the author of at least one package which does so added
  1131.   several delay loops to his code simply to make it look as if there was
  1132.   actually some work involved.
  1133.  
  1134. - Use of insecure algorithms designed by "experts".  An example is the standard
  1135.   Unix crypt command, which is an implementation of a rotor machine much like
  1136.   the German Enigma cipher which was broken during WWII.  There is a program
  1137.   called cbw (for `crypt breakers workbench') which can automatically decrypt
  1138.   data encrypted with crypt.  After the war, the US government even sold Enigma
  1139.   cipher machines to third-world governments without telling them that they
  1140.   knew how to break this form of encryption.
  1141.  
  1142. - Use of incorrectly-implemented algorithms.  Some encryption programs use the
  1143.   DES algorithm, which consists of a series of complicated and arbitrary-
  1144.   seeming bit transformations controlled by complex lookup tables.  These
  1145.   transformations and tables are very easy to get wrong.
  1146.  
  1147.   A well-known fact about the DES algorithm is that even the slightest
  1148.   deviation from the correct implementation significantly weakens the algorithm
  1149.   itself.  In other words any implementation which doesn't conform 100% to the
  1150.   standard may encrypt and decrypt data perfectly, but is in practice rather
  1151.   easier to break than the real thing.
  1152.  
  1153.   The US National Bureau of Standards (now the National Institute of Standards
  1154.   and Technology) provides a reference standard for DES encryption.  A
  1155.   disappointingly large number of commercial implementations fail this test.
  1156.  
  1157. - Use of badly-implemented algorithms.  This is another problem which besets
  1158.   many DES implementations.  DES can be used in several modes of operation,
  1159.   some of them better than others.  The simplest of these is the Electronic
  1160.   Codebook (ECB) mode, in which a block of data is broken up into seperate
  1161.   subblocks which correspond to the unit of data which DES can encrypt or
  1162.   decrypt in one operation, and each subblock is then encrypted seperately.
  1163.  
  1164.   There also exist other modes such as CBC in which one block of encrypted data
  1165.   is chained to the next (such that the ciphertext block n depends not only on
  1166.   the corresponding plaintext but also on all preceding ciphertext blocks
  1167.   0..n-1), and CFB, which is a means of converting a block cipher to a stream
  1168.   cipher with similar chaining properties.
  1169.  
  1170.   There are several forms of attack which can be used when an encrypted message
  1171.   consists of a large number of completely independant message blocks.  It is
  1172.   often possible to identify by inspection repeated blocks of data, which may
  1173.   correspond to patterns like long strings of spaces in text.  This can be used
  1174.   as the basis for a known-plaintext attack.
  1175.  
  1176.   ECB mode is also open to so-called message modification attacks.  Lets assume
  1177.   that Bob asks his bank to deposit $10,000 in account number 12-3456-789012-3.
  1178.   The bank encrypts the message `Deposit $10,000 in account number
  1179.   12-3456-789012-3' and sends it to its central office.  Encrypted in ECB mode
  1180.   this looks as follows:
  1181.  
  1182.     E( Deposit $10,000 in acct. number 12-3456-789012-3 )
  1183.  
  1184.   Bob intercepts this message, and records it.  The encrypted message looks as
  1185.   follows:
  1186.  
  1187.     H+2nx/GHEKgvldSbqGQHbrUfotYFtUk6gS4CpMIuH7e2MPZCe
  1188.  
  1189.   Later on in the day, he intercepts the following a message:
  1190.  
  1191.     H+2nx/GHEKgvldSbqGQHbrUfotYFtUk61Pts2LtOHa8oaNWpj
  1192.  
  1193.   Since each block of text is completely independant of any surrounding block,
  1194.   he can simply insert the blocks corresponding to his account number:
  1195.  
  1196.     ................................gS4CpMIuH7e2MPZCe
  1197.  
  1198.   in place of the existing blocks, and thus alter the encrypted data without
  1199.   any knowledge of the encryption key used.  Bob has since gone on to early
  1200.   retirement in his new Hawaiian villa.
  1201.  
  1202.   ECB mode, and the more secure modes such as CBC and CFB are described in
  1203.   several standards.  Some of these standards make a reference to the
  1204.   insecurity of ECB mode, and recommend the use of the stronger CBC or CFB
  1205.   modes.  Usually implementors stop reading at the section on ECB, with the
  1206.   result being that many commercial packages which use DES and which do manage
  1207.   to get it correct end up using it in ECB mode.
  1208.  
  1209. - Protocol errors.  Even if a more secure encryption mode such as CBC or CFB
  1210.   mode is used, there can still be problems.  If a standard message format
  1211.   (such as the one shown above) is used, modification is still possible, except
  1212.   that now instead of changing individual parts of a message the entire message
  1213.   must be altered, since each piece of data is dependant on all previous parts.
  1214.   This can be avoided by prepending a random initialisation vector (IV) to each
  1215.   message, which propagates through the message itself to generate a completely
  1216.   different ciphertext each time the same message is encrypted.  The use of the
  1217.   salt in Unix password encryption is an example of an IV, although the range
  1218.   of only 4096 values is too small to provide real security.
  1219.  
  1220. In some ways, cryptography is like pharmaceuticals.  Its integrity is
  1221. important.  Bad penicillin looks just the same as good penicillin.  Determining
  1222. whether most software is correct or not is simple - just look at the output.
  1223. However the ciphertext produced by a weak encryption algorithm looks no
  1224. different from the ciphertext produced by a strong algorithm.... until an
  1225. opponent starts using your supposedly secure data against you, or you find your
  1226. money transfers are ending up in an account somewhere in Switzerland, or
  1227. financing Hawaiian villas.
  1228.  
  1229.  
  1230. Design Details
  1231. --------------
  1232.  
  1233. This section goes into a few of the more obscure details not covered in the
  1234. section on security analysis, such as the encryption algorithm used by SFS, the
  1235. generation of random numbers, the handling of initialization vectors (IV's),
  1236. and a brief overview on the deletion of sensitive information retained in
  1237. memory after a program has terminated (this is covered in more detail in the
  1238. section "Security Analysis" above).
  1239.  
  1240.  
  1241. The Encryption Algorithm used in SFS
  1242.  
  1243. Great care must be taken when choosing an encryption algorithm for use in
  1244. security software.  For example, the standard Unix crypt(1) command is based on
  1245. a software implementation of a rotor machine encryption device of the kind
  1246. which was broken by mathematicians using pencil and paper in the late 1930's.
  1247. Indeed, there exists a program called `crypt breaker's workbench' which allows
  1248. the automated breaking of data encrypted using the crypt(1) command.  The
  1249. insecurity of various other programs has been mentioned elsewhere.  It is
  1250. therefore imperative that a reliable encryption system, based on world-wide
  1251. security standards, and easily verifiable by consulting these standards, be
  1252. used.
  1253.  
  1254. When a block cipher is used as a stream cipher by running it in CFB (cipher
  1255. feedback) mode, there is no need for the cipher's block transformation to be a
  1256. reversible one as it is only ever run in one direction (generally
  1257. encrypt-only).  Therefore the use of a reversible cipher such as DES or IDEA is
  1258. unnecessary, and any secure one-way block transformation can be substituted.
  1259. This fact allows the use of one-way hash functions, which have much larger
  1260. block sizes (128 or more bits) and key spaces (512 or more bits) than most
  1261. reversible block ciphers in use today.
  1262.  
  1263. The transformation involved in a one-way hash function takes an initial hash
  1264. value H and a data block D, and hashes it to create a new hash value H':
  1265.  
  1266.     hash( H, D ) -> H'
  1267.  
  1268. or, more specifically, in the function used in SFS:
  1269.  
  1270.     H + hash( D ) -> H'
  1271.  
  1272. This operation is explained in more detail in FIPS Pub. 180 which defines the
  1273. Secure Hash Standard.  By using H as the data block to be encrypted and D as
  1274. the key, we can make the output value H' dependant on a user-supplied key.
  1275. That is, when H is the plaintext, D is the encryption key, and H' is the
  1276. ciphertext:
  1277.  
  1278.      plaintext H
  1279.          |
  1280.          v
  1281.     +---------+
  1282.     |   SHS   |<- key D
  1283.     +---------+
  1284.          |
  1285.          v
  1286.     ciphertext H'
  1287.  
  1288. If we regard it as a block cipher, the above becomes:
  1289.  
  1290.     H' = SHS( H )
  1291.  
  1292. which is actually:
  1293.  
  1294.     C  =   e( P )
  1295.  
  1296. Since we can only ever "encrypt" using a one-way hash function, we need to run
  1297. the "cipher" in cipher feedback mode, which doesn't require a reversible
  1298. encryption algorithm.
  1299.  
  1300. By the properties of the hash function, it is computationally infeasible to
  1301. either recover the key D or to control the transformation H -> H' (in other
  1302. words given a value for H' we cannot predict the H which generated it, and
  1303. given control over the value H we cannot generate an arbitrary H' from it).
  1304.  
  1305. The MDC encryption algorithm is a general encryption system which will take any
  1306. one-way hash function and turn it into a stream cipher running in CFB mode.
  1307. The recommended one-way hash function for MDC is the Secure Hash Standard as
  1308. specified in Federal Information Processing Standards (FIPS) Publication 180.
  1309. SHS is used as the block transformation in a block cipher run in CFB mode as
  1310. detailed in AS 2805.5.2 section 8 and ISO 10116:1991 section 6, with the two
  1311. parameters (the size of the feedback and plaintext variables) j and k both
  1312. being set to the SHS block size of 160 bits.  The properties of this mode of
  1313. operation are given in Appendix A3 of AS 2805.5.2 and Annex A.3 of ISO
  1314. 10116:1991.  The CFB mode of operation is also detailed in a number of other
  1315. standards such as FIPS Publication 81 and USSR Government Standard GOST
  1316. 28147-89, Section 4.  The use of an initialization vector (IV) is as given in
  1317. ISO 10126-2:1991 section 4.2, except that the size of the IV is increased to
  1318. 160 bits from the 48 or 64 bits value given in the standard. This is again
  1319. detailed in a number of other standards such as GOST 28147-89 Section 3.1.2.
  1320. The derivation of the IV is given in the section "Encryption Considerations"
  1321. below.
  1322.  
  1323. The key setup for the MDC encryption algorithm is performed by running the
  1324. cipher over the encryption key (in effect encrypting the key with MDC using
  1325. itself as the key) and using the encrypted value as the new encryption key.
  1326. This procedure is then repeated a number of times to make a "brute-force"
  1327. decryption attack more difficult, as per the recommendation in the Public-Key
  1328. Cryptography Standard (PKCS), part 1.  This reduces any input key, even one
  1329. which contains regular data patterns, to a block of white noise equal in size
  1330. to the MDC key data.
  1331.  
  1332. The exact key scheduling process for MDC is as follows:
  1333.  
  1334.  Initialization:
  1335.  
  1336.  - The SHS hash value H is set to the key IV[1].
  1337.  - The SHS data block D is set to all zeroes.
  1338.  - The key data of length 2048 bits is set to a 16-bit big-endian value
  1339.    containing the length of the user key in bytes, followed by up to 2032 bits
  1340.    of user key.
  1341.  
  1342.    SHS hash value H = key IV;
  1343.    SHS data block D = zeroes;
  1344.    key_data [0:15] = length of user key in bytes;
  1345.    key_data [16:2048 ] = user key, zero-padded;
  1346.  
  1347.  Key schedule:
  1348.  
  1349.  - The following process is iterated a number of times:
  1350.  
  1351.    - The 2048-bit key data block is encrypted using MDC.
  1352.    - Enough of the encrypted key data is copied from the start of the key data
  1353.      block into the SHS data block D to fill it.
  1354.  
  1355.    for i = 1 to 200 do
  1356.        encrypted_key = encrypt( key_data );
  1357.        D = encrypted_key;
  1358.  
  1359. During the repeated encryptions, the IV is never reset.  This means that the IV
  1360. from the end of the n-1 th data block is re-injected into the start of the n th
  1361. data block.  After 200 iterations, the "randomness" present in the key has been
  1362. diffused throughout the entire key data block.
  1363.  
  1364. Although the full length of the key data block is 2048 bits, the SHS algorithm
  1365. only uses 512 bits of this (corresponding to the SHS data block D) per
  1366. iteration.  The remaining 1536 bits take part in the computation (by being
  1367. carried along via the IV) but are not used directly.  By current estimates
  1368. there are around 2^256 atoms in the universe.  Compiling a table of all 2^512
  1369. possible keys which would be necessary for a brute-force attack on MDC would
  1370. therefore be a considerable challenge to an attacker, requiring, at least, the
  1371. creation of another 512 * 2^256 universes to hold all the keys.  Even allowing
  1372. for the current best-case estimate of a creation time of 7 days per universe,
  1373. the mere creation of storage space for all the keys would take an unimaginably
  1374. large amount of time.
  1375.  
  1376. The SFS key schedule operation has been deliberately designed to slow down
  1377. special hardware implementations, since the encryption algorithm is rekeyed
  1378. after each iteration.  Normal high-speed password-cracking hardware would (for
  1379. example, with DES) have 16 separate key schedules in a circular buffer, each
  1380. being applied to a different stage of a 16-stage pipeline (one stage per DES
  1381. round) allowing a new result to be obtained in every clock cycle once the
  1382. pipeline is filled.  In MDC the key data is reused multiple times during the 80
  1383. rounds of SHS, requiring 80 separate key schedules for the same performance as
  1384. the 16 DES ones.  However since the algorithm is rekeyed after every iteration
  1385. for a total of 200 iterations, this process must either be repeated 200 times
  1386. (for a corresponding slowdown factor of 200), or the full pipeline must be
  1387. extended to 16,000 stages to allow the one-result-per-cycle performance which
  1388. the 16-stage DES pipeline can deliver (assuming the rekeying operation can be
  1389. performed in a single cycle).  Changing the iteration count to a higher value
  1390. will further slow down this process.
  1391.  
  1392. The number of iterations of key encryption is controlled by the user, and is
  1393. generally done some hundreds of times.  The setup process in SFS has been tuned
  1394. to take approximately half a second on a workstation rated at around 15 MIPS
  1395. (corresponding to 200 iterations of the encryption process), making a
  1396. brute-force password attack very time-consuming.  Note that the key IV is
  1397. injected at the earliest possible moment in the key schedule rather than at the
  1398. very end, making the use of a precomputed data attack impossible.  The standard
  1399. method of injecting the encryption IV at the end of the key schedule process
  1400. offers very little protection against an attack using precomputed data, as it
  1401. is still possible to precompute the key schedules and simply drop in the
  1402. encryption IV at the last possible moment.
  1403.  
  1404. Footnote [1]: Some sources would refer to this value as a `salt'.  The term
  1405.               `key IV' is used here as this is probably a more accurate
  1406.               description of its function.
  1407.  
  1408.  
  1409. Generating Random Numbers
  1410.  
  1411. One thing which cryptosystems consume in large quantities are random numbers.
  1412. Not just any old random value, but cryptographically strong random numbers.  A
  1413. cryptographically strong random value is one which cannot be predicted by an
  1414. attacker (if the attacker can predict the value, which is usually used to set
  1415. up encryption keys, then they can make a guess at the encryption key itself).
  1416. This automatically rules out all software means of generating random values,
  1417. and means specialised hardware must be used.
  1418.  
  1419. Very few PC's are currently equipped with this type of hardware.  However SFS
  1420. requires 1024 random bits for each encrypted disk, in the form of the disk key
  1421. (see the section "[Password Lifetimes and Scope]" above).  SFS therefore uses a
  1422. number of sources of random numbers, both ones present in the hardware of the
  1423. PC and one external source:
  1424.  
  1425.   - Various hardware timers which are read occasionally when the program is
  1426.     running (generally after operations which are long and complex and will be
  1427.     heavily affected by external influences such as interrupts, video, screen,
  1428.     and disk I/O, and other factors.
  1429.  
  1430.   - The contents and status information of the keyboard buffer
  1431.  
  1432.   - Disk driver controller and status information
  1433.  
  1434.   - Mouse data and information
  1435.  
  1436.   - Video controller registers and status information
  1437.  
  1438. [ - The clock skew between two hardware clocks available on the PC.  Due to
  1439.     background system activity such as interrupt servicing, disk activity, and
  1440.     variable-length instruction execution times, these clocks run out-of-phase.
  1441.     SFS uses this phase difference as a source of random numbers].
  1442.  
  1443.   - The timing of keystrokes when the password is entered.  SFS reads the
  1444.     high-speed 1.19 MHz hardware timer after each keystroke and uses the timer
  1445.     values as a source of random numbers.  This timer is used both to measure
  1446.     keystroke latency when the password is entered and read at random times
  1447.     during program execution.  Trials have shown that this 16-bit counter
  1448.     yields around 8 bits of random information (the exact information content
  1449.     is difficult to gauge as background interrupts, video updates, disk
  1450.     operations, protected-mode supervisor software, and other factors greatly
  1451.     affect any accesses to this counter, but an estimate of 8 bits is probably
  1452.     close enough[1]).
  1453.  
  1454.   - The timing of disk access latency.  The exact operation is as follows:
  1455.  
  1456.         Read a timer-based random disk sector
  1457.         Add its contents (8 bits)
  1458.         Read the high-speed 1.19 MHz hardware timer (13 bits)
  1459.         Use the two values for the next random sector
  1460.  
  1461.     This is repeated as often as required (in the case of SFS this is 10
  1462.     times).  Assuming a (currently rather optimistic) maximum of 5ms to acquire
  1463.     a sector this provides about 13 bits of randomness per disk operation.  The
  1464.     number of factors which influence this value is rather high, and includes
  1465.     among other things the time it takes the BIOS to process the request, the
  1466.     time it takes the controller to process the request, time to seek to the
  1467.     track on the disk, time to read the data (or, if disk cacheing is used,
  1468.     time for the occasional cache hit), time to send it to the PC, time to
  1469.     switch in and out of protected mode when putting it in the cache, and of
  1470.     course the constant 3-degree background radiation of other interrupts and
  1471.     system activity happening at the same time.  If a solid-state disk were
  1472.     being used, the hardware latency would be significantly reduced, but
  1473.     currently virtually no 386-class PC's have solid-state disks (they're
  1474.     reserved for palmtops and the like), so this isn't a major concern.
  1475.  
  1476. An estimate of the number of random bits available from each source is as
  1477. follows:
  1478.  
  1479.     Keystroke latency, 8 bits per key      80 bits for minimum 10-char key
  1480.     Second password entry for encryption   80 bits for minimum 10-char key
  1481.     Disk access latency, 13 bits per read 130 bits for 10 reads
  1482.     Disk sector data, 8 bits               80 bits for 10 reads
  1483.     System clocks and timers                3 bits
  1484.     Video controller information            4 bits
  1485.     Keyboard buffer information             4 bits
  1486.     Disk status information                 4 bits
  1487.     General system status                   4 bits
  1488.     Random high-speed timer reads         120 bits for 15 reads
  1489.                                           --------
  1490.     Total                                 509 bits
  1491.  
  1492. These figures are very conservative estimates only, and are based on timing
  1493. experiments with typed-in passwords and a careful scrutiny of the PC's hardware
  1494. and system status data.  In practice (especially with longer passwords) the
  1495. number of random bits is increased somewhat (for example with a 30-character
  1496. password the total may be as high as 829 bits of random information).  However
  1497. even the minimal estimate of 509 bits is adequate for the 512-bit key required
  1498. by MDC.
  1499.  
  1500. Each quantum of semi-random information is exclusive-ored into a 1024-bit
  1501. buffer which is initially set to all zeroes.  Once 1024 bits of buffer have
  1502. been filled, the data is encrypted with MDC to distribute the information, and
  1503. the first 512 bits of the 1024-bit buffer is used as the key for the next MDC
  1504. encyrption pass.  Then more data is added until, again, 1024 bits of buffer
  1505. have been filled, whereupon the data is again mixed by encrypting it with MDC.
  1506. This process is repeated several times, with the amount of "randomness" in the
  1507. buffer increasing with each iteration.
  1508.  
  1509. Before being used, this data is encrypted 10 times over with MDC to ensure a
  1510. complete diffusion of randomness.  Since the IV for the encryption is reused
  1511. for the next pass through the buffer, any information from the end of the
  1512. buffer is thus reinjected at the start of the buffer at the next encryption
  1513. pass.
  1514.  
  1515. Although this method of generating random numbers is not perfect, it seems to
  1516. be the best available using the existing hardware.  General estimates of the
  1517. exact amount of truly random information which can be acquired in this manner
  1518. are in the vicinity of several hundred bits.  However these all assume that an
  1519. attacker is in possession of what amounts to a complete hardware trace of
  1520. events on the machine in question.  Allowing for a reasonable amount of
  1521. physical system security, it can be assumed that the random data used in SFS is
  1522. unpredictable enough to provide an adequate amount of security against all but
  1523. the most determined attacker.
  1524.  
  1525. Footnote [1]: If an opponent can obtain several hours of keystroke timings and
  1526.               can come up with a good model including serial correlations, they
  1527.               may be able to reduce the likely inputs to the random number
  1528.               accumulator to a somewhat smaller value, or at least bias their
  1529.               guesses to fall within the range of likely values.
  1530.  
  1531.  
  1532. Encryption Considerations
  1533.  
  1534. When a block cipher is converted to handle units of data larger than its
  1535. intrinsic block size, a number of weaknesses can be introduced, depending on
  1536. the mode of operation which is chosen for the block cipher.  For example, if
  1537. two identical ciphertext blocks are present in different locations in a file,
  1538. this may be used to determine the plaintext.  If we can find two identical
  1539. blocks of ciphertext when cipher block chaining (CBC) is used, then we know
  1540. that:
  1541.  
  1542.     P[ i ] = d( C[ i ] ) ^ C[ i-1 ]
  1543.     P[ j ] = d( C[ j ] ) ^ C[ j-1 ]
  1544.  
  1545. where C is the ciphertext, P is the plaintext, and e() and d() are encryption
  1546. and decryption respectively.  Now if C[ i ] = C[ j ], then d( C[ i ] ) =
  1547. d( C[ j ] ), which cancel out when xor'd so that:
  1548.  
  1549.     P[ i ] ^ C[ i-1 ] = P[ j ] ^ C[ j-1 ]
  1550.  
  1551. or:
  1552.  
  1553.      P[ j ] = P[ i ] ^ C[ i-1 ] ^ C[ j-1 ]
  1554.  
  1555. Knowing C[ i ] and C[ j ] we can determine P[ i ] and P[ j ], and knowing
  1556. either P[ i ] or P[ j ] we can determine the other.
  1557.  
  1558. Something similar holds when cipher feedback (CFB) mode is used, except that
  1559. now the decryption operation is:
  1560.  
  1561.     P[ i ] = e( C[ i-1 ] ) ^ C[ i ]
  1562.     P[ j ] = e( C[ j-1 ] ) ^ C[ j ]
  1563.  
  1564. Now if C[ i ] = C[ j ] then e( C[ i ] ) = e( C[ j ] ) (recall that in CFB mode
  1565. the block cipher is only ever used for encryption), so that they again cancel
  1566. out, so:
  1567.  
  1568.     P[ i ] ^ e( C[ i-1 ] ) = P[ j ] ^ e( C[ j-1 ] )
  1569.  
  1570. or:
  1571.  
  1572.     P[ i ] = P[ j ] ^ e( C[ i-1 ] ) ^ e( C[ j-1 ] )
  1573.  
  1574. In general this problem is of little consequence since the probability of
  1575. finding two equal blocks of ciphertext when using a 160-bit block cipher on a
  1576. dataset of any practical size is negligible.  More esoteric modes of operation
  1577. such as plaintext feedback (PFB) and ones whose acronyms have more letters than
  1578. Welsh place names tend to have their own special problems and aren't considered
  1579. here.
  1580.  
  1581. The problem does become serious, however, in the case of sector-level
  1582. encryption, where the initialization vector cannot be varied.  Although the IV
  1583. may be unique for each sector, it remains constant unless special measures such
  1584. as reserving extra storage for sector IV's which are updated with each sector
  1585. write are taken.  If a sector is read from disk, a small change made to part of
  1586. it (for example changing a word in a text file), and the sector written out to
  1587. disk again, several unchanged ciphertext/plaintext pairs will be present,
  1588. allowing the above attack to be applied.  Running a program such as a disk
  1589. defragmenter will rewrite a large number of sectors while leaving the IV
  1590. unchanged, allowing an opponent access to large quantities of XOR'd plaintext
  1591. blocks simply by recording the disk contents before and after the
  1592. defragmentation process.  Normally this problem would be avoided by using a
  1593. different IV for each encrypted message, but most disk systems don't have the
  1594. room to store an entire sectors worth of data as well as the IV needed to
  1595. en/decrypt it.
  1596.  
  1597. An additional disadvantage of the CFB encryption mode is that the data in the
  1598. last block of a dataset may be altered by an attacker to give different
  1599. plaintext without it affecting the rest of the block since the altered
  1600. ciphertext in the last block never enters the feedback loop.  This type of
  1601. attack requires that an opponent possess at least two copies of the ciphertext,
  1602. and that they differ only in the contents of the last block.  In this case the
  1603. last ciphertext block from one copy can be subsituted for the last ciphertext
  1604. block in the other copy, allowing a subtle form of message modification attack.
  1605. In fact in combination with the previously mentioned weakness of CFB, an
  1606. attacker can determine the XOR of the plaintexts in the last block and
  1607. substitute an arbitrary piece of "encrypted" plaintext to replace the existing
  1608. data.
  1609.  
  1610. There are several approaches to tackling this problem.  The most simplistic one
  1611. is to permute the plaintext in a key-dependant manner before encryption and
  1612. after decryption.  This solution is unsatisfactory as it simply shuffles the
  1613. data around without necessarily affecting any particular plaintext or
  1614. ciphertext block.  The desired goal of a change in any part of the plaintext
  1615. affecting the entire dataset is not achieved.
  1616.  
  1617. A better solution is to encrypt data twice, once from front to back and then
  1618. from back to front[1].  The front-to-back pass propagates any dependencies to
  1619. the back of the dataset, and the back-to-front pass propagates dependencies
  1620. back to the front again.  In this way a single change in any part of the
  1621. plaintext affects the entire dataset.  The disadvantage of this approach is
  1622. that it at least halves the speed of the encryption, as all data must be
  1623. encrypted twice. If the encryption is done in software, this may create an
  1624. unacceptable loss of throughput.  Even with hardware assistance there is a
  1625. noticeable slowdown, as no hardware implementations easily support backwards
  1626. encryption, requiring the data to be reversed in software before the second
  1627. pass is possible.
  1628.  
  1629. The best solution is probably to use a word-wise scrambler polynomial like the
  1630. one used in SHA.  With a block of plaintext P this is:
  1631.  
  1632.     P[ i ] ^= P[ i-K1 ] ^ P[ i-K2 ]
  1633.  
  1634. with suitable values for the constants K1 and K2.  If K2 is chosen to be 5 (the
  1635. SHA block size in words) then the initial values of the 5 words (which can be
  1636. thought of as as P[ -5 ]...P[ -1 ]) are simply the sectorIV.  The value of K1
  1637. is arbitrary, SFS uses a value of 4.
  1638.  
  1639. This technique is used by first setting the initial values of the 5 words to
  1640. the sectorIV.  The scrambler function is then run over the entire data block,
  1641. propagating all dependencies to the last 5 words in the block.  These last 5
  1642. words are then used as the IV for the CFB encryption of the entire block.  In
  1643. this way the encryption IV depends on all the bits in the block, and the
  1644. scrambling does a moderately good job of breaking up statistical patterns in
  1645. the plaintext.  No information is lost, so no randomness in the sectorIV is
  1646. misplaced.
  1647.  
  1648. This also provides resistance to the selective-modification attack which allows
  1649. an attacker to change selected bits in the last block of a CFB-encrypted
  1650. dataset without damage.  By destroying the IV used in the CFB encryption, the
  1651. first block is completely corrupted, which is unlikely to go unnoticed.
  1652.  
  1653. To decrypt a dataset encrypted in this manner, the first 5 words of ciphertext
  1654. are shifted into the feedback path, and the remainder of the dataset is
  1655. decrypted in the standard manner.  The last 5 decrypted words are then used as
  1656. the IV to decrypt the first encrypted block.  Finally, the scrambler is run
  1657. over the recovered plaintext to undo the changes made during the encryption
  1658. scrambling.
  1659.  
  1660. The overall en/decryption process used by SFS, in the case of 512-byte sectors
  1661. and 32-bit words (so that each sector contains 128 words), is:
  1662.  
  1663.     Encryption:
  1664.  
  1665.         using sectorIV[ 0 ]...sectorIV[ 4 ] as the scrambler IV
  1666.             scramble data[ 0 ]...data[ 127 ]
  1667.         using data[ 127-5 ]...data[ 127-1 ] as the encryption IV
  1668.             encrypt data[ 0 ]...data[ 127 ]
  1669.  
  1670.     Decryption:
  1671.  
  1672.         using data[ 0 ]...data[ 4 ] as the encryption IV
  1673.             decrypt data[ 5 ]...data[ 127 ]
  1674.         using data[ 127-5 ]...data[ 127-1 ] as the encryption IV
  1675.             decrypt data[ 0 ]...data[ 4 ]
  1676.         using sectorIV[ 0 ]...sectorIV[ 4 ] as the scrambler IV
  1677.             scramble data[ 0 ]...data[ 127 ]
  1678.  
  1679. where the scrambling operation is:
  1680.  
  1681.         data[ i ] ^= data[ i-4 ] ^ data[ i-5 ]
  1682.  
  1683. as outlined above.  Note that the i-4 and i-5 th values referred to here are
  1684. the original, scrambled values, not the descrambled values.  The easiest way to
  1685. implement this is to cache the last 5 scrambled values and cyclically overwrite
  1686. them as each word in the data buffer is processed.
  1687.  
  1688. Footnote [1]:  To be precise, you need some sort of feedback from the end of
  1689.                a block on the first encryption pass to the start of the block
  1690.                on the next encryption pass.  A block can be encrypted forwards
  1691.                twice as long as the IV is wrapped around back to the start of
  1692.                the block for the second encryption pass.
  1693.  
  1694.  
  1695. A Discussion of the MDC Encryption Algorithm[1]
  1696.  
  1697. (A word on notation:  The notation {0,1}^k is used to mean the set of all bit
  1698. strings of length k, and {0,1}* means the set of all bit strings, including the
  1699. empty string.  Any message can be viewed as a bit string by means of a suitable
  1700. encoding.)
  1701.  
  1702. The encryption method used by SFS is somewhat unusual.  In some respects it is
  1703. similar to Merkle's "Meta Method" for obtaining cryptosystems.  The method
  1704. relies on the existence of secure one-way hash functions.  A hash function is a
  1705. function that takes as input an arbitrary number of bits and produces a
  1706. fixed-sized output called the "message digest".  In other words, hash functions
  1707. have the form
  1708.  
  1709.     h : {0,1}* --> {0,1}^k              for some fixed k,
  1710.  
  1711. and the hash of a message M is defined to be h( M ).  A secure one-way hash
  1712. function is a hash function with the following properties:
  1713.  
  1714.     1. For each message M, it is easy to compute h( M ),
  1715.  
  1716.     2. Given M, it is computationally infeasible to compute M' with
  1717.        h( M ) = h( M' ) (secure against forgery), and
  1718.  
  1719.     3. It is computationally infeasible to compute M and M' with
  1720.        h( M ) = h( M' ) (secure against collisions).
  1721.  
  1722. (For a good, although rather technical discussion of hash functions, or indeed
  1723. cryptography in general, see "Contemporary Cryptology. The Science of
  1724. Information Integrity" edited by Gustavus Simmons, IEEE Press, 1992 (ISBN
  1725. 0-87942-277-7)).
  1726.  
  1727. The terms "easy to compute" and "infeasible to compute" can be made precise,
  1728. but we'll settle for this informal terminology anyway.  Roughly, "easy to
  1729. compute" means that it will take a tolerable amount of time to compute the
  1730. answer, even on a rather small machine; "infeasible to compute" means that it
  1731. should take eons to find out a particular result, even when using millions of
  1732. computers of the fastest conceivable technology in parallel.
  1733.  
  1734. Examples of hash functions include the MD2, MD4, and MD5 hash functions,
  1735. developed by Ron Rivest of RSA Data Security, Inc., which have been (at least
  1736. in the case of MD4 and MD5) placed in the public domain, and the Secure Hash
  1737. Standard SHS, developed by NIST (with significant input from the NSA).  The
  1738. existence of secure one-way hash functions has not been proved, although there
  1739. exist some strong candidates, including MD5 and SHS.
  1740.  
  1741. The reference implementations of the above hashing functions include one
  1742. interesting aspect which makes it possible to use them as encryption functions.
  1743. Since the hashing of a very large amount of data in one sweep is not desirable
  1744. (because all the data would have to be in memory at the time of hashing), most
  1745. hashing algorithms allow you to hash data incrementally.  This is made possible
  1746. by augmenting the definition of a hash function to include the state of the
  1747. last hashing operation.  In other words, a hash function now has the form
  1748.  
  1749.     h : {0,1}^k x {0,1}* --> {0,1}^k,
  1750.  
  1751. where the first argument is the previous hash value, and the hash of a message
  1752. M = ( M1, M2, ..., Mn ) is defined to be
  1753.  
  1754.     h( h( ...( h( h0, M1 ), M2 ), ... ), Mn ).
  1755.  
  1756. (The value of all the h evaluations must not change if the message is broken up
  1757. into blocks of different length, but all of the previously mentioned hash
  1758. functions have that property).  Here, h0 is a fixed, known initial value that
  1759. is used in all hashing calculations.
  1760.  
  1761. This is not the way "real" hash functions behave, but it is close enough.  For
  1762. example, the MD5 hashing function has "initialization", "updating", and
  1763. "finalization" parts, where the finalization part appends the number of hashed
  1764. bytes to the message, hashes one final time, and returns the final hash value.
  1765. This means that the hashing "context" must include the number of bytes hashed
  1766. so far, without it being a part of the hash value.  The hash function can be
  1767. said to have "memory".
  1768.  
  1769. If we assume that h is a secure one-way hashing function, we can now use such
  1770. an h as a scrambling device.  For example, if we set E( M ) = h( h0, M ) for
  1771. every message M, M will not be recoverable from E( M ), because h is secure by
  1772. definition.  Another method would be to supply M to any standard MSDOS or UNIX
  1773. utility and use the resulting error message as the ciphertext.  (Remember, a
  1774. computer is a device for turning input into error messages).  However, there
  1775. are still two problems to be solved before we can use hash functions as
  1776. encryption functions:
  1777.  
  1778.     1. The scrambling process is not controlled by a key, and
  1779.  
  1780.     2. The scrambling process is not invertible, so there is no way to
  1781.        decrypt the ciphertext.
  1782.  
  1783. Both problems can be solved by interchanging the roles of hash and data and by
  1784. using CFB mode in the encryption process.  In other words, let K be an
  1785. arbitrarily long key, let M = ( M1, ..., Mn ) be a message, broken up in chunks
  1786. of k bits, let IV be an initialization vector, and set
  1787.  
  1788.     C1 = M1 xor h( IV, K )
  1789.     Ci = Mi xor h( C( i-1 ), K )        for 1 < i <= n.
  1790.  
  1791. This is sent to the recipient, who easily recovers the plaintext by
  1792.  
  1793.     P1 = C1 xor h( IV, K )
  1794.     Pi = Ci xor h( C( i-1 ), K )        for 1 < i <= n,
  1795.  
  1796. since we have
  1797.  
  1798.     P1 = ( M1 xor h( IV, K ) ) xor h( IV, K )
  1799.        = M1 xor ( h( IV, K ) xor h( IV,K ) )    because xor is associative,
  1800.        = M1 xor 0,                      because x xor x = 0,
  1801.        = M1,                            because x xor 0 = x,
  1802.  
  1803. and similarly for the Pi's.  This method of encryption also offers more
  1804. security than using ECB mode, assuming that this were possible with hash
  1805. functions, since the plaintext is diffused over the entire ciphertext,
  1806. destroying plaintext statistics, and thus foiling straightforward ciphertext
  1807. correlation attacks.
  1808.  
  1809. This method can clearly be used for any hash function which can hash
  1810. incrementally.  Thus, it is a "Meta Method" for turning hash functions into
  1811. encryption functions.  This is called the Message Digest Cipher (MDC) method of
  1812. encryption.  Specific instances of the method have the name of the hash
  1813. function added as a suffix.  For example, the MDC method applied to the MD5
  1814. hash function would be referred to as MDC/MD5.  SFS uses MDC/SHS.
  1815.  
  1816. Footnote [1]: This analysis was contributed by Stephan Neuhaus,
  1817.               <neuhaus@informatik.uni-kl.de>
  1818.  
  1819.  
  1820. Deletion of SFS Volumes
  1821.  
  1822. Truly deleting data from magnetic media is very difficult.  The problem lies in
  1823. the fact that when data is written to the medium, the write head sets the
  1824. polarity of most, but not all, of the magnetic domains.  This is partially due
  1825. to the inability of the writing device to write in exactly the same location
  1826. each time, and partially due to the variations in media sensitivity and field
  1827. strength over time and among devices.
  1828.  
  1829. In general terms, when a one is written to disk, the media records a one, and
  1830. when a zero is written, the media records a zero.  However the actual effect is
  1831. closer to obtaining something like 0.95 when a zero is overwritten with a one,
  1832. and 1.05 when a one is overwritten with a one.  Normal disk circuitry is set up
  1833. so that both these values are read as ones, but using specialized circuitry it
  1834. is possible to work out what previous `layers' contained (in fact on some
  1835. systems it may be possible to recover previous data with a simple software
  1836. modification to the hardware control code).
  1837.  
  1838. This problem is further complicated by the fact that the heads might not pass
  1839. exactly over the same track position when data is rewritten, leaving a trace of
  1840. the old data still intact.  Current-generation drives reduce this problem
  1841. somewhat as track and linear densities have now become so high that the
  1842. traditional optical methods of extracting information from the disk platters
  1843. has become much more difficult, and in some cases impossible, as the linear bit
  1844. cell is below the optical diffraction limit for visible light.  While some data
  1845. patterns can still be discerned, recognizing others would be limited to some
  1846. subset of patterns.
  1847.  
  1848. Despite this small respite, when all the above factors are combined it turns
  1849. out that each track on a piece of media contains an image of everything ever
  1850. written to it, but that the contribution from each `layer' gets progressively
  1851. smaller the further back it was made.  Using the same signal-processing
  1852. technology which is used to clean up satellite images, low-level recorded
  1853. speech, and other data, it is possible to recover previous data with a
  1854. remarkable degree of accuracy back to a level limited only by the sensitivity
  1855. of the equipment and the amount of expertise of the organisation attempting the
  1856. recovery.  Intelligence organisations have a *lot* of expertise in this field.
  1857.  
  1858. The basic concept behind the overwriting scheme used by SFS is to flip each
  1859. magnetic domain on the disk back and forth as much as possible (this is the
  1860. basic idea behind degaussing - magnetic media are limited in their ability to
  1861. store high-frequency oscillations, so we try to flip the bits as rapidly as
  1862. possible).  This means that the disk head should be run at the highest possible
  1863. frequency, and the same pattern should not be written twice in a row.  If the
  1864. data was encoded directly, that would mean a an alternating pattern of ones and
  1865. zeroes.  However, disks always use a NRZI encoding scheme in which a 1 bit
  1866. signifies an inversion, making the desired pattern a series of one bits.  This
  1867. leads to a further complication as all disks use some form of run-length
  1868. limited (RLL) encoding, so that the adjacent ones won't be written.  This
  1869. encoding is used so that transitions aren't placed too closely together, or too
  1870. far apart, which would mean the drive would lose track of where it was in the
  1871. data.
  1872.  
  1873. The basic limitation on disks is the proximity of 1 bits.  Floppies (which are
  1874. a more primitive form of the technology used in hard disks) like to keep the 1
  1875. bits 4us apart.  However they can't be kept too far apart or the read clock
  1876. loses synchronisation.  This "too far" figure depends a lot on the technology
  1877. in the drive, it doesn't depend on the magnetic media much (unlike the "too
  1878. close" figure, which depends a lot on the media involved).  The first
  1879. single-density encoding wrote one user data bit, then one "1" clock bit, taking
  1880. a total of 8us.  This was called FM, since a 1 bit was encoded as two
  1881. transitions (1 wavelength) per 8 us, while a 0 bit was encoded as one
  1882. transition (1/2 wavelength).
  1883.  
  1884. Then it was discovered that it was possible to have two 0 bits between adjacent
  1885. 1s.  The resulting encoding of 4 bits into 5 was called group code recording
  1886. (GCR) which was (0,2) RLL.  This allowed 4 user data bits to be written in
  1887. 5 * 4us = 20 us, for an effective time per user bit of 5 us, which was a big
  1888. improvement over 8 us.
  1889.  
  1890. But GCR encoding was somewhat complex.  A different approach was taken in
  1891. modified FM (MFM), which suppressed the 1 clock bit except between adjacent
  1892. 0's.  Thus, 0000 turned into 0(1)0(1)0(1)0 (where the ()s are the inserted
  1893. clock bits), 1111 turned into 1(0)1(0)1(0)1, and 1010 turned into
  1894. 1(0)0(0)1(0)0.  The maximum time between 1 bits was now three 0 bits.  However,
  1895. there was at least one 0 bit, so it became possible to clock the bits at
  1896. 2us/bit and not have more than one 1 bit every 4us.  This achieved one user bit
  1897. per 4 us, a result which was better than GCR and obtainable with simpler
  1898. circuitry.  As can be seen, the effective data rate depends on the bit rate
  1899. (which has been 4 us, 4 us and 2 us in these examples) and the encoding rate, a
  1900. measure of the encoding efficiency. The encoding rates have been 1/2, 4/5 and
  1901. 1/2.
  1902.  
  1903. There is a (2,7) RLL code with rate 1/2, meaning that 1 user bit goes to 2
  1904. encoded bits (although the mapping involves multi-bit groups and is somewhat
  1905. complex), but there are always at least two 0 bits between 1 bits, so 1 bits
  1906. happen at most every 3 bit times.  This allows the clock to be reduced to
  1907. 1.3333 us (this 2/1.33333 = 6/4 = 3/2 is the source of the added capacity gain
  1908. of RLL hard drive controllers over equivalent MFM controllers).  The time per
  1909. user bit is now 2.6666 = 2 2/3 us.
  1910.  
  1911. However, the faster clock is finicky.  It is also possible to use a (1,7) RLL
  1912. encoding.  Since this is (1,x), the clock rate is 2 us/bit, but the encoding
  1913. efficiency improves from 1/2 to 2/3.  This allows 2 effective user bits per 6
  1914. us, or 3 us per user bit.  For hard drives, it is easier to increase the clock
  1915. rate by an extra 9/8 than to fiddle with a clock 50% faster, so this is very
  1916. popular with more recent disk drives.
  1917.  
  1918. The three most common RLL codes are (1,3) RLL (usually known as MFM), (2,7) RLL
  1919. (the original "RLL" format), and (1,7) RLL (which is popular in newer drives).
  1920. The origins of these codes are explained in more details below.  Fortunately,
  1921. each of these three have commonly-used encoding tables.  A knowledge of these
  1922. tables can be used to design overwrite patterns with lots of transitions after
  1923. being encoded with whatever encoding technique the drive uses.
  1924.  
  1925. For MFM, the patterns to write to produce this are 0000 and 1111.  So a couple
  1926. of rounds of this should be included in the overwrite pattern. MFM drives are
  1927. the oldest, lowest-density drives around (this is especially true for the
  1928. very-low-density floppy drives).  As such, they're the easiest to recover data
  1929. from with modern equipment and we need to take the most care with them.
  1930.  
  1931. For (1,7) RLL, the patterns to write are 0011 and 1100, or 0x33 and 0xCC when
  1932. expressed as bytes.  To provide some security against bit misalignment, the
  1933. values 0x99 and 0x66 should be included as well (although drive manufacturers
  1934. like to keep things byte-aligned, so this sort of bit misalignment is unlikely
  1935. to happen).
  1936.  
  1937. For (2,7) RLL drives, three patterns are necessary, and the problem of byte
  1938. endianness question rears its head.  The previous two cases are not
  1939. significantly affected by shifting the bytes around, but this one is.
  1940. Fortunately, thanks to the strong influence of IBM mainframe drives, everything
  1941. seems to be uniformly big-endian within bytes (that is, the most significant
  1942. bit is written to the disk first).
  1943.  
  1944. For (2,7) RLL using the standard tables:
  1945.  
  1946.   10   -> 0100
  1947.   11   -> 1000
  1948.   000  -> 00100
  1949.   010  -> 100100
  1950.   011  -> 001000
  1951.   0010 -> 00100100
  1952.   0011 -> 00001000
  1953.  
  1954. the bit patterns 100100100..., 010010010... and 001001001... will encode into
  1955. the maximum-frequency encoded strings 010010010010... (0x49, 0x24, 0x92),
  1956. 100100100100... (0x92, 0x49, 0x24), and 001001001001.... (0x24, 0x92, 0x49).
  1957. Writing all three of these patterns will cover all the bases.
  1958.  
  1959. For the latest crop of high-density drives which use methods like Partial-
  1960. Response Maximum-Likelihood (PRML) methods which may be roughly equated to the
  1961. trellis encoding done by V.32 modems in that it is effective but
  1962. computationally expansive)m all we can do is write a variety of random
  1963. patterns, because the processing inside the drive is too complex to
  1964. second-guess.  Fortunately, these drives push the limits of the magnetic media
  1965. much more than the old MFM drives ever did by encoding data with much smaller
  1966. magnetic domains, closer to the physical capacity of the magnetic media.  If
  1967. these drives require sophisticated signal processing just to read the most
  1968. recently written data, reading overwritten layers is also correspondingly more
  1969. difficult.  A good scrubbing with random data will do about as well as can be
  1970. expected.
  1971.  
  1972. To deal with all these types of drives in one overwrite pattern, SFS uses the
  1973. following sequence of 30 consecutive writes to erase data:
  1974.  
  1975.    1.  Random
  1976.    2.  0000..., MFM encoded to 01010101...
  1977.    3.  1111..., MFM encoded to 10101010...
  1978.    4.  Random
  1979.    5.  010010..., (2,7) RLL encoded to 100100100100...
  1980.    6.  100100..., (2,7) RLL encoded to 010010010010...
  1981.    7.  001001..., (2,7) RLL encoded to 001001001001...
  1982.    8.  Random
  1983.    9.  00110011..., (1,7) RLL encoded to 010101010101...
  1984.   10.  11001100..., (1,7) RLL encoded to 101010101010...
  1985.   11.  01100110..., (1,7) misaligned RLL encoded to 010101010101...
  1986.   12.  10011001..., (1,7) misaligned RLL encoded to 101010101010...
  1987.   13.  Random
  1988.   14.  1111..., MFM encoded to 10101010...
  1989.   15.  0000..., MFM encoded to 01010101...
  1990.   16.  Random
  1991.   17.  001001..., (2,7) RLL encoded to 001001001001...
  1992.   18.  100100..., (2,7) RLL encoded to 010010010010...
  1993.   19.  010010..., (2,7) RLL encoded to 100100100100...
  1994.   20.  Random
  1995.   21.  11001100..., (1,7) RLL encoded to 101010101010...
  1996.   22.  00110011..., (1,7) RLL encoded to 010101010101...
  1997.   23.  10011001..., (1,7) misaligned RLL encoded to 101010101010...
  1998.   24.  01100110..., (1,7) misaligned RLL encoded to 010101010101...
  1999.   25.  Random
  2000.   26.  0000..., MFM encoded to 01010101...
  2001.   27.  1111..., MFM encoded to 10101010...
  2002.   28.  Random
  2003.   29.  Random
  2004.   30.  Random
  2005.  
  2006. All patterns are repeated twice, once in each order, and MFM is repeated three
  2007. times, because MFM drives are generally the lowest density, and thus
  2008. particularly easy to examine.
  2009.  
  2010. There is a commonly-held belief that there is a US government standard for
  2011. declassifying magnetic media which involves overwriting it three times.  In
  2012. fact this method is for declassifying core (computer memory) rather than
  2013. magnetic media.  The government standard for declassifying magnetic media
  2014. probably involves concentrated acid, furnaces, belt sanders, or any combination
  2015. of the above.  This is necessary not only because data recovery from the actual
  2016. tracks itself may (with some effort) be possible, but because of factors like
  2017. like intelligent drives which keep so-called "alternative cylinders" on a disk
  2018. free to allow dynamic re-allocation of data to one of these tracks in case a
  2019. disk block develops errors.  The original block is no longer accessible through
  2020. any sort of normal access mechanism, and the data on it can't be destroyed
  2021. without going through some unusual contortions which tend to be highly
  2022. hardware-dependant.  Similarly, drives conforming to some of the more
  2023. high-level protocols such as SCSI are relatively free to interpret commands
  2024. sent to them in whichever way they choose (as long as they still conform to the
  2025. SCSI specification).  Thus some drives, if sent a SCSI Format Media command may
  2026. return immediately without performing any action, may simply perform a read
  2027. test on the entire disk (the most common option), or may actually write data to
  2028. the disk[1].  This is rather common among newer drives which can't directly be
  2029. low-level formatted, unlike older ST-412 and ST-506 MFM or RLL drives.  For
  2030. example trying to format an IDE drive generally has little effect - a low-level
  2031. format generally isn't possible, and the standard DOS `format' command simply
  2032. writes a boot record, FAT, and root directory, and returns.
  2033.  
  2034. Therefore if the data is very sensitive and is stored on floppy disk, it can
  2035. best be destroyed by removing the media from the disk liner and burning it.
  2036. Disks are relatively cheap, and can easily be replaced.  Permanently destroying
  2037. data on fixed disks is less simple, but the multiple-overwrite option used by
  2038. SFS at least makes it quite challenging (and expensive) to recover any
  2039. information.
  2040.  
  2041. Footnote [1]:  Again it may be possible to bypass this using highly hardware-
  2042.                specific methods.  For example Quantum SCSI drives manufactured
  2043.                a few years ago could be forced to write data to disk during a
  2044.                format by changing the sector filler byte before the format
  2045.                command was issued.
  2046.